logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma
commit: a8137159c2363ec842b14f72288b26cf677f6f6a
parent: 4b2a586942edd5510e1835d57149387292052523
Author: kaniini <nenolod@gmail.com>
Date:   Thu, 25 Oct 2018 03:11:19 +0000

Merge branch 'feature/in-reply-to-screen-name' into 'develop'

initial graph traversal support

Closes #68

See merge request pleroma/pleroma!387

Diffstat:

Mlib/pleroma/activity.ex6++++++
Mlib/pleroma/web/twitter_api/representers/activity_representer.ex10++++++++++
Mlib/pleroma/web/twitter_api/views/activity_view.ex10++++++++++
Mtest/web/twitter_api/representers/activity_representer_test.exs1+
Mtest/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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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,