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

initial graph traversal support

Closes #68

See merge request pleroma/pleroma!387
This commit is contained in:
kaniini 2018-10-25 03:11:19 +00:00
commit a8137159c2
5 changed files with 28 additions and 0 deletions

View file

@ -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

View file

@ -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,

View file

@ -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,

View file

@ -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)

View file

@ -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,