forked from mirrors/akkoma
Merge branch 'feature/add-in-reply-to-profileurl' into 'develop'
twitterapi graph enrichment See merge request pleroma/pleroma!388
This commit is contained in:
commit
4646794ee2
5 changed files with 20 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue