twitterapi: activity view: implement in_reply_to_screen_name using the new graph...
authorWilliam Pitcock <nenolod@dereferenced.org>
Thu, 25 Oct 2018 02:54:29 +0000 (02:54 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Thu, 25 Oct 2018 02:59:04 +0000 (02:59 +0000)
lib/pleroma/web/twitter_api/representers/activity_representer.ex
lib/pleroma/web/twitter_api/views/activity_view.ex

index b21bbb205f6553113536ed7016d1137a76a30487..04857001cdef9f1dc3ea6591be0881d0ca838771 100644 (file)
@@ -180,6 +180,15 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
 
     attachments = (object["attachment"] || []) ++ video
 
+    reply_parent = Activity.get_in_reply_to_activity(activity)
+
+    reply_user_nickname =
+      if reply_parent do
+        User.get_cached_by_ap_id(reply_parent.actor).nickname
+      else
+        nil
+      end
+
     %{
       "id" => activity.id,
       "uri" => activity.data["object"]["id"],
@@ -190,6 +199,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
       "is_post_verb" => true,
       "created_at" => created_at,
       "in_reply_to_status_id" => object["inReplyToStatusId"],
+      "in_reply_to_screen_name" => reply_user_nickname,
       "statusnet_conversation_id" => conversation_id,
       "attachments" => attachments |> ObjectRepresenter.enum_to_list(opts),
       "attentions" => attentions,
index b9fd062d6fa6a257f6b548827c645a890b149a0e..13fb04f952cb82004c25deb626b6daea7cf768dc 100644 (file)
@@ -236,6 +236,15 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
       HTML.filter_tags(content, User.html_filter_policy(opts[:for]))
       |> Formatter.emojify(object["emoji"])
 
+    reply_parent = Activity.get_in_reply_to_activity(activity)
+
+    reply_user_nickname =
+      if reply_parent do
+        User.get_cached_by_ap_id(reply_parent.actor).nickname
+      else
+        nil
+      end
+
     %{
       "id" => activity.id,
       "uri" => activity.data["object"]["id"],
@@ -246,6 +255,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
       "is_post_verb" => true,
       "created_at" => created_at,
       "in_reply_to_status_id" => object["inReplyToStatusId"],
+      "in_reply_to_screen_name" => reply_user_nickname,
       "statusnet_conversation_id" => conversation_id,
       "attachments" => (object["attachment"] || []) |> ObjectRepresenter.enum_to_list(opts),
       "attentions" => attentions,