1 defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
2 use Pleroma.Web.TwitterAPI.Representers.BaseRepresenter
3 alias Pleroma.Web.TwitterAPI.Representers.{UserRepresenter, ObjectRepresenter}
6 def to_map(%Activity{} = activity, %{user: user} = opts) do
7 content = get_in(activity.data, ["object", "content"])
8 published = get_in(activity.data, ["object", "published"])
10 mentions = opts[:mentioned] || []
12 attentions = activity.data["to"]
13 |> Enum.map(fn (ap_id) -> Enum.find(mentions, fn(user) -> ap_id == user.ap_id end) end)
15 |> Enum.map(fn (user) -> UserRepresenter.to_map(user, opts) end)
19 "user" => UserRepresenter.to_map(user, opts),
21 "statusnet_html" => content,
24 "is_post_verb" => true,
25 "created_at" => published,
26 "in_reply_to_status_id" => activity.data["object"]["inReplyToStatusId"],
27 "statusnet_conversation_id" => activity.data["object"]["statusnetConversationId"],
28 "attachments" => (activity.data["object"]["attachment"] || []) |> ObjectRepresenter.enum_to_list(opts),
29 "attentions" => attentions