Introduce get_by_id in Activity, replace newlines with spaces

This commit is contained in:
rinpatch 2019-01-15 20:00:21 +03:00
parent 850912b06b
commit ff6c9a5c96
4 changed files with 7 additions and 4 deletions

View file

@ -207,7 +207,7 @@ config :pleroma, :gopher,
ip: {0, 0, 0, 0}, ip: {0, 0, 0, 0},
port: 9999 port: 9999
config :pleroma, :metadata, opengraph: true config :pleroma, :metadata, providers: []
config :pleroma, :suggestions, config :pleroma, :suggestions,
enabled: false, enabled: false,

View file

@ -36,6 +36,9 @@ defmodule Pleroma.Activity do
) )
end end
def get_by_id(id) do
Repo.get(Activity, id)
end
# TODO: # TODO:
# Go through these and fix them everywhere. # Go through these and fix them everywhere.
# Wrong name, only returns create activities # Wrong name, only returns create activities

View file

@ -47,6 +47,7 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraph do
content content
# html content comes from DB already encoded, decode first and scrub after # html content comes from DB already encoded, decode first and scrub after
|> HtmlEntities.decode() |> HtmlEntities.decode()
|> String.replace(~r/<br\s?\/?>/, " ")
|> HTML.strip_tags() |> HTML.strip_tags()
|> Formatter.truncate() |> Formatter.truncate()
end end

View file

@ -7,7 +7,6 @@ defmodule Pleroma.Web.OStatus.OStatusController do
alias Pleroma.{User, Activity, Object} alias Pleroma.{User, Activity, Object}
alias Pleroma.Web.OStatus.{FeedRepresenter, ActivityRepresenter} alias Pleroma.Web.OStatus.{FeedRepresenter, ActivityRepresenter}
alias Pleroma.Repo
alias Pleroma.Web.{OStatus, Federator} alias Pleroma.Web.{OStatus, Federator}
alias Pleroma.Web.XML alias Pleroma.Web.XML
alias Pleroma.Web.ActivityPub.ObjectView alias Pleroma.Web.ActivityPub.ObjectView
@ -141,7 +140,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do
end end
def notice(conn, %{"id" => id}) do def notice(conn, %{"id" => id}) do
with {_, %Activity{} = activity} <- {:activity, Repo.get(Activity, id)}, with {_, %Activity{} = activity} <- {:activity, Activity.get_by_id(id)},
{_, true} <- {:public?, ActivityPub.is_public?(activity)}, {_, true} <- {:public?, ActivityPub.is_public?(activity)},
%User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do
case format = get_format(conn) do case format = get_format(conn) do