aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaniini <nenolod@gmail.com>2018-10-25 03:11:19 +0000
committerkaniini <nenolod@gmail.com>2018-10-25 03:11:19 +0000
commita8137159c2363ec842b14f72288b26cf677f6f6a (patch)
treedcb390d926a2b94085be706a183db77b95d61ab2
parent4b2a586942edd5510e1835d57149387292052523 (diff)
parent9563f3766d45e6c95fe50e371bc0048d9f4a2452 (diff)
downloadpleroma-a8137159c2363ec842b14f72288b26cf677f6f6a.tar.gz
Merge branch 'feature/in-reply-to-screen-name' into 'develop'
initial graph traversal support Closes #68 See merge request pleroma/pleroma!387
-rw-r--r--lib/pleroma/activity.ex6
-rw-r--r--lib/pleroma/web/twitter_api/representers/activity_representer.ex10
-rw-r--r--lib/pleroma/web/twitter_api/views/activity_view.ex10
-rw-r--r--test/web/twitter_api/representers/activity_representer_test.exs1
-rw-r--r--test/web/twitter_api/views/activity_view_test.exs1
5 files changed, 28 insertions, 0 deletions
diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex
index bed96861f..c065f3b6c 100644
--- a/lib/pleroma/activity.ex
+++ b/lib/pleroma/activity.ex
@@ -82,4 +82,10 @@ defmodule Pleroma.Activity do
def normalize(obj) when is_map(obj), do: Activity.get_by_ap_id(obj["id"])
def normalize(ap_id) when is_binary(ap_id), do: Activity.get_by_ap_id(ap_id)
def normalize(_), do: nil
+
+ def get_in_reply_to_activity(%Activity{data: %{"object" => %{"inReplyTo" => ap_id}}}) do
+ get_create_activity_by_object_ap_id(ap_id)
+ end
+
+ def get_in_reply_to_activity(_), do: nil
end
diff --git a/lib/pleroma/web/twitter_api/representers/activity_representer.ex b/lib/pleroma/web/twitter_api/representers/activity_representer.ex
index b21bbb205..04857001c 100644
--- a/lib/pleroma/web/twitter_api/representers/activity_representer.ex
+++ b/lib/pleroma/web/twitter_api/representers/activity_representer.ex
@@ -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,
diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex
index b9fd062d6..13fb04f95 100644
--- a/lib/pleroma/web/twitter_api/views/activity_view.ex
+++ b/lib/pleroma/web/twitter_api/views/activity_view.ex
@@ -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,
diff --git a/test/web/twitter_api/representers/activity_representer_test.exs b/test/web/twitter_api/representers/activity_representer_test.exs
index 894d20049..ae6f62ed0 100644
--- a/test/web/twitter_api/representers/activity_representer_test.exs
+++ b/test/web/twitter_api/representers/activity_representer_test.exs
@@ -139,6 +139,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
"is_post_verb" => true,
"created_at" => "Tue May 24 13:26:08 +0000 2016",
"in_reply_to_status_id" => 213_123,
+ "in_reply_to_screen_name" => nil,
"statusnet_conversation_id" => convo_object.id,
"attachments" => [
ObjectRepresenter.to_map(object)
diff --git a/test/web/twitter_api/views/activity_view_test.exs b/test/web/twitter_api/views/activity_view_test.exs
index b9a8efdad..3ab87d6fa 100644
--- a/test/web/twitter_api/views/activity_view_test.exs
+++ b/test/web/twitter_api/views/activity_view_test.exs
@@ -36,6 +36,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
"favorited" => false,
"id" => activity.id,
"in_reply_to_status_id" => nil,
+ "in_reply_to_screen_name" => nil,
"is_local" => true,
"is_post_verb" => true,
"possibly_sensitive" => false,