Fix some stupid typos
[akkoma] / lib / pleroma / web / twitter_api / views / activity_view.ex
index 0699bf1da9f0d0b737cff5720e65c134746b4265..adac1dfe9fe5761e31f4cfc7e20e603878b2b226 100644 (file)
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
 defmodule Pleroma.Web.TwitterAPI.ActivityView do
   use Pleroma.Web, :view
   alias Pleroma.Web.CommonAPI.Utils
@@ -241,9 +245,16 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
 
     html =
       content
-      |> HTML.filter_tags(User.html_filter_policy(opts[:for]))
+      |> Utils.get_scrubbed_html(User.html_filter_policy(opts[:for]), activity)
       |> Formatter.emojify(object["emoji"])
 
+    text =
+      if content do
+        content
+        |> String.replace(~r/<br\s?\/?>/, "\n")
+        |> HTML.strip_tags()
+      end
+
     reply_parent = Activity.get_in_reply_to_activity(activity)
 
     reply_user = reply_parent && User.get_cached_by_ap_id(reply_parent.actor)
@@ -253,7 +264,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
       "uri" => activity.data["object"]["id"],
       "user" => UserView.render("show.json", %{user: user, for: opts[:for]}),
       "statusnet_html" => html,
-      "text" => HTML.strip_tags(content),
+      "text" => text,
       "is_local" => activity.local,
       "is_post_verb" => true,
       "created_at" => created_at,
@@ -296,7 +307,8 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
     {summary, content}
   end
 
-  def render_content(%{"type" => object_type} = object) when object_type in ["Article", "Page"] do
+  def render_content(%{"type" => object_type} = object)
+      when object_type in ["Article", "Page", "Video"] do
     summary = object["name"] || object["summary"]
 
     content =