From 3b799f22b7cd6afd9fb8bc8c7800ec770585a957 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 23 Jun 2018 06:08:09 +0000 Subject: [PATCH 1/5] twitterapi: activity view: expose message summary text --- lib/pleroma/web/twitter_api/views/activity_view.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index f418249e2..55b5287f5 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -255,7 +255,8 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do "tags" => tags, "activity_type" => "post", "possibly_sensitive" => possibly_sensitive, - "visibility" => Pleroma.Web.MastodonAPI.StatusView.get_visibility(object) + "visibility" => Pleroma.Web.MastodonAPI.StatusView.get_visibility(object), + "summary" => summary } end From 152a526237abb846b96a3c7b4001c8bd0c7409f9 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 24 Jun 2018 05:33:34 +0000 Subject: [PATCH 2/5] twitter api: refactor activity html generation, add support for Articles --- lib/pleroma/web/twitter_api/views/activity_view.ex | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index 55b5287f5..cb7c4cb96 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -262,7 +262,6 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do def render_content(%{"type" => "Note"} = object) do summary = object["summary"] - content = if !!summary and summary != "" do "

#{summary}

#{object["content"]}" @@ -275,7 +274,6 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do def render_content(%{"type" => "Article"} = object) do summary = object["name"] || object["summary"] - content = if !!summary and summary != "" do "

#{summary}

#{object["content"]}" From f03e57f7647f4d302359680c7eb7fe48433c7beb Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 24 Jun 2018 06:22:53 +0000 Subject: [PATCH 3/5] twitter api: activity representer: add summary field for testsuite --- lib/pleroma/web/twitter_api/representers/activity_representer.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/twitter_api/representers/activity_representer.ex b/lib/pleroma/web/twitter_api/representers/activity_representer.ex index bb77e61f3..26bfb79af 100644 --- a/lib/pleroma/web/twitter_api/representers/activity_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/activity_representer.ex @@ -191,7 +191,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do "tags" => tags, "activity_type" => "post", "possibly_sensitive" => possibly_sensitive, - "visibility" => Pleroma.Web.MastodonAPI.StatusView.get_visibility(object) + "visibility" => Pleroma.Web.MastodonAPI.StatusView.get_visibility(object), + "summary" => object["summary"] } end From 4fb64c1d862692bb869dd735e9772195b7cf2705 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 24 Jun 2018 06:23:19 +0000 Subject: [PATCH 4/5] testsuite: twitter api: add summary where necessary --- test/web/twitter_api/representers/activity_representer_test.exs | 3 ++- test/web/twitter_api/views/activity_view_test.exs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/web/twitter_api/representers/activity_representer_test.exs b/test/web/twitter_api/representers/activity_representer_test.exs index 7505093dd..3f85e028b 100644 --- a/test/web/twitter_api/representers/activity_representer_test.exs +++ b/test/web/twitter_api/representers/activity_representer_test.exs @@ -155,7 +155,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do "activity_type" => "post", "possibly_sensitive" => true, "uri" => activity.data["object"]["id"], - "visibility" => "direct" + "visibility" => "direct", + "summary" => "2hu" } assert ActivityRepresenter.to_map(activity, %{ diff --git a/test/web/twitter_api/views/activity_view_test.exs b/test/web/twitter_api/views/activity_view_test.exs index 5b2a7466b..a101e4ae8 100644 --- a/test/web/twitter_api/views/activity_view_test.exs +++ b/test/web/twitter_api/views/activity_view_test.exs @@ -48,7 +48,8 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do "text" => "Hey @shp!", "uri" => activity.data["object"]["id"], "user" => UserView.render("show.json", %{user: user}), - "visibility" => "direct" + "visibility" => "direct", + "summary" => nil } assert result == expected From b832df1e158aa945a3c481804da0a839f18d46c5 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 12 Jul 2018 16:12:54 +0000 Subject: [PATCH 5/5] formatting --- lib/pleroma/web/twitter_api/views/activity_view.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index cb7c4cb96..55b5287f5 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -262,6 +262,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do def render_content(%{"type" => "Note"} = object) do summary = object["summary"] + content = if !!summary and summary != "" do "

#{summary}

#{object["content"]}" @@ -274,6 +275,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do def render_content(%{"type" => "Article"} = object) do summary = object["name"] || object["summary"] + content = if !!summary and summary != "" do "

#{summary}

#{object["content"]}"