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

twitterapi graph enrichment

See merge request pleroma/pleroma!388
This commit is contained in:
kaniini 2018-10-25 04:16:40 +00:00
commit 4646794ee2
5 changed files with 20 additions and 14 deletions

View File

@ -42,6 +42,10 @@ defmodule Pleroma.User do
end end
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 def ap_id(%User{nickname: nickname}) do
"#{Web.base_url()}/users/#{nickname}" "#{Web.base_url()}/users/#{nickname}"
end end

View File

@ -182,12 +182,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
reply_parent = Activity.get_in_reply_to_activity(activity) reply_parent = Activity.get_in_reply_to_activity(activity)
reply_user_nickname = reply_user = reply_parent && User.get_cached_by_ap_id(reply_parent.actor)
if reply_parent do
User.get_cached_by_ap_id(reply_parent.actor).nickname
else
nil
end
%{ %{
"id" => activity.id, "id" => activity.id,
@ -199,7 +194,10 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
"is_post_verb" => true, "is_post_verb" => true,
"created_at" => created_at, "created_at" => created_at,
"in_reply_to_status_id" => object["inReplyToStatusId"], "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, "statusnet_conversation_id" => conversation_id,
"attachments" => attachments |> ObjectRepresenter.enum_to_list(opts), "attachments" => attachments |> ObjectRepresenter.enum_to_list(opts),
"attentions" => attentions, "attentions" => attentions,

View File

@ -238,12 +238,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
reply_parent = Activity.get_in_reply_to_activity(activity) reply_parent = Activity.get_in_reply_to_activity(activity)
reply_user_nickname = reply_user = reply_parent && User.get_cached_by_ap_id(reply_parent.actor)
if reply_parent do
User.get_cached_by_ap_id(reply_parent.actor).nickname
else
nil
end
%{ %{
"id" => activity.id, "id" => activity.id,
@ -255,7 +250,10 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
"is_post_verb" => true, "is_post_verb" => true,
"created_at" => created_at, "created_at" => created_at,
"in_reply_to_status_id" => object["inReplyToStatusId"], "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, "statusnet_conversation_id" => conversation_id,
"attachments" => (object["attachment"] || []) |> ObjectRepresenter.enum_to_list(opts), "attachments" => (object["attachment"] || []) |> ObjectRepresenter.enum_to_list(opts),
"attentions" => attentions, "attentions" => attentions,

View File

@ -140,6 +140,9 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
"created_at" => "Tue May 24 13:26:08 +0000 2016", "created_at" => "Tue May 24 13:26:08 +0000 2016",
"in_reply_to_status_id" => 213_123, "in_reply_to_status_id" => 213_123,
"in_reply_to_screen_name" => nil, "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, "statusnet_conversation_id" => convo_object.id,
"attachments" => [ "attachments" => [
ObjectRepresenter.to_map(object) ObjectRepresenter.to_map(object)

View File

@ -37,6 +37,9 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
"id" => activity.id, "id" => activity.id,
"in_reply_to_status_id" => nil, "in_reply_to_status_id" => nil,
"in_reply_to_screen_name" => 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_local" => true,
"is_post_verb" => true, "is_post_verb" => true,
"possibly_sensitive" => false, "possibly_sensitive" => false,