From ff6c9a5c961647b64c3c9fcc05932093595e9588 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 15 Jan 2019 20:00:21 +0300 Subject: [PATCH] Introduce get_by_id in Activity, replace newlines with spaces --- config/config.exs | 2 +- lib/pleroma/activity.ex | 5 ++++- lib/pleroma/web/metadata/opengraph.ex | 1 + lib/pleroma/web/ostatus/ostatus_controller.ex | 3 +-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config/config.exs b/config/config.exs index 895dbb3ab..b8c208cb4 100644 --- a/config/config.exs +++ b/config/config.exs @@ -207,7 +207,7 @@ config :pleroma, :gopher, ip: {0, 0, 0, 0}, port: 9999 -config :pleroma, :metadata, opengraph: true +config :pleroma, :metadata, providers: [] config :pleroma, :suggestions, enabled: false, diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index 353f9f6cd..47562306d 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -35,7 +35,10 @@ defmodule Pleroma.Activity do ) ) end - + + def get_by_id(id) do + Repo.get(Activity, id) + end # TODO: # Go through these and fix them everywhere. # Wrong name, only returns create activities diff --git a/lib/pleroma/web/metadata/opengraph.ex b/lib/pleroma/web/metadata/opengraph.ex index 5f8bed2fb..6d86c0ee6 100644 --- a/lib/pleroma/web/metadata/opengraph.ex +++ b/lib/pleroma/web/metadata/opengraph.ex @@ -47,6 +47,7 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraph do content # html content comes from DB already encoded, decode first and scrub after |> HtmlEntities.decode() + |> String.replace(~r//, " ") |> HTML.strip_tags() |> Formatter.truncate() end diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex index be648a6ee..2a47519d1 100644 --- a/lib/pleroma/web/ostatus/ostatus_controller.ex +++ b/lib/pleroma/web/ostatus/ostatus_controller.ex @@ -7,7 +7,6 @@ defmodule Pleroma.Web.OStatus.OStatusController do alias Pleroma.{User, Activity, Object} alias Pleroma.Web.OStatus.{FeedRepresenter, ActivityRepresenter} - alias Pleroma.Repo alias Pleroma.Web.{OStatus, Federator} alias Pleroma.Web.XML alias Pleroma.Web.ActivityPub.ObjectView @@ -141,7 +140,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do end 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)}, %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do case format = get_format(conn) do