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 @@ def banner_url(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

View File

@ -182,12 +182,7 @@ def to_map(
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 @@ def to_map(
"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,

View File

@ -238,12 +238,7 @@ def render(
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 @@ def render(
"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,

View File

@ -140,6 +140,9 @@ test "an activity" 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)

View File

@ -37,6 +37,9 @@ test "a create activity with a note" 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,