TwitterAPI: Display cws.
authorRoger Braun <roger@rogerbraun.net>
Tue, 31 Oct 2017 16:43:37 +0000 (17:43 +0100)
committerRoger Braun <roger@rogerbraun.net>
Tue, 31 Oct 2017 16:43:37 +0000 (17:43 +0100)
lib/pleroma/web/twitter_api/representers/activity_representer.ex
test/web/twitter_api/representers/activity_representer_test.exs

index 929e26bf0ff1dfe3bb0f40bce37ab26e1ff54f07..3fbeb86ba94c50c8438a9eab65e28bcd2407b643 100644 (file)
@@ -135,6 +135,12 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
     tags = activity.data["object"]["tag"] || []
     possibly_sensitive = Enum.member?(tags, "nsfw")
 
+    content = if activity.data["object"]["summary"] do
+      "<span>#{activity.data["object"]["summary"]}</span><br>#{content}</span>"
+    else
+      content
+    end
+
     html = HtmlSanitizeEx.basic_html(content) |> Formatter.emojify(object["emoji"])
 
     %{
index f08644611639154c4e27285fe46f6cc9d98f97aa..7e2ea630ca185f8bee57df0ad280b3266c8802a0 100644 (file)
@@ -91,6 +91,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
           "published" => date,
           "type" => "Note",
           "content" => content_html,
+          "summary" => "2hu",
           "inReplyToStatusId" => 213123,
           "attachment" => [
             object
@@ -110,14 +111,14 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
       local: false
     }
 
-    expected_html = "alert('YAY')Some <img height='32px' width='32px' alt='2hu' title='2hu' src='corndog.png' /> content mentioning <a href=\"#{mentioned_user.ap_id}\">@shp</a>"
+    expected_html = "<span>2hu</span><br />alert('YAY')Some <img height='32px' width='32px' alt='2hu' title='2hu' src='corndog.png' /> content mentioning <a href=\"#{mentioned_user.ap_id}\">@shp</a>"
 
     expected_status = %{
       "id" => activity.id,
       "user" => UserView.render("show.json", %{user: user, for: follower}),
       "is_local" => false,
       "statusnet_html" => expected_html,
-      "text" => content,
+      "text" => "2hu" <> content,
       "is_post_verb" => true,
       "created_at" => "Tue May 24 13:26:08 +0000 2016",
       "in_reply_to_status_id" => 213123,