logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma
commit: 4646794ee2502e9ffd57943a3bb0231d3f235b2b
parent: a8137159c2363ec842b14f72288b26cf677f6f6a
Author: kaniini <nenolod@gmail.com>
Date:   Thu, 25 Oct 2018 04:16:40 +0000

Merge branch 'feature/add-in-reply-to-profileurl' into 'develop'

twitterapi graph enrichment

See merge request pleroma/pleroma!388

Diffstat:

Mlib/pleroma/user.ex4++++
Mlib/pleroma/web/twitter_api/representers/activity_representer.ex12+++++-------
Mlib/pleroma/web/twitter_api/views/activity_view.ex12+++++-------
Mtest/web/twitter_api/representers/activity_representer_test.exs3+++
Mtest/web/twitter_api/views/activity_view_test.exs3+++
5 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex @@ -42,6 +42,10 @@ defmodule Pleroma.User do end end + def profile_url(%User{info: %{"source_data" => %{"url" => url}}}), do: url + def profile_url(%User{ap_id: ap_id}), do: ap_id + def profile_url(_), do: nil + def ap_id(%User{nickname: nickname}) do "#{Web.base_url()}/users/#{nickname}" end diff --git a/lib/pleroma/web/twitter_api/representers/activity_representer.ex b/lib/pleroma/web/twitter_api/representers/activity_representer.ex @@ -182,12 +182,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do 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 + reply_user = reply_parent && User.get_cached_by_ap_id(reply_parent.actor) %{ "id" => activity.id, @@ -199,7 +194,10 @@ 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, + "in_reply_to_screen_name" => reply_user && reply_user.nickname, + "in_reply_to_profileurl" => User.profile_url(reply_user), + "in_reply_to_ostatus_uri" => reply_user && reply_user.ap_id, + "in_reply_to_user_id" => reply_user && reply_user.id, "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 @@ -238,12 +238,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do 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 + reply_user = reply_parent && User.get_cached_by_ap_id(reply_parent.actor) %{ "id" => activity.id, @@ -255,7 +250,10 @@ 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, + "in_reply_to_screen_name" => reply_user && reply_user.nickname, + "in_reply_to_profileurl" => User.profile_url(reply_user), + "in_reply_to_ostatus_uri" => reply_user && reply_user.ap_id, + "in_reply_to_user_id" => reply_user && reply_user.id, "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 @@ -140,6 +140,9 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do "created_at" => "Tue May 24 13:26:08 +0000 2016", "in_reply_to_status_id" => 213_123, "in_reply_to_screen_name" => nil, + "in_reply_to_user_id" => nil, + "in_reply_to_profileurl" => nil, + "in_reply_to_ostatus_uri" => 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 @@ -37,6 +37,9 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do "id" => activity.id, "in_reply_to_status_id" => nil, "in_reply_to_screen_name" => nil, + "in_reply_to_user_id" => nil, + "in_reply_to_profileurl" => nil, + "in_reply_to_ostatus_uri" => nil, "is_local" => true, "is_post_verb" => true, "possibly_sensitive" => false,