end
end
+ defp get_context_id(%{data: %{"context_id" => context_id}}) when not is_nil(context_id),
+ do: context_id
+
+ defp get_context_id(%{data: %{"context" => context}}) when is_binary(context),
+ do: Utils.context_to_conversation_id(context)
+
+ defp get_context_id(_), do: nil
+
def render("index.json", opts) do
replied_to_activities = get_replied_to_activities(opts.activities)
content =
object
|> render_content()
- |> HTML.get_cached_scrubbed_html_for_object(
+ |> HTML.get_cached_scrubbed_html_for_activity(
User.html_filter_policy(opts[:for]),
activity,
- __MODULE__
+ "mastoapi:content"
+ )
+
+ summary =
+ (object["summary"] || "")
+ |> HTML.get_cached_scrubbed_html_for_activity(
+ User.html_filter_policy(opts[:for]),
+ activity,
+ "mastoapi:summary"
)
card = render("card.json", Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity))
content: content,
created_at: created_at,
reblogs_count: announcement_count,
- replies_count: 0,
+ replies_count: object["repliesCount"] || 0,
favourites_count: like_count,
reblogged: present?(repeated),
favourited: present?(favorited),
muted: CommonAPI.thread_muted?(user, activity) || User.mutes?(opts[:for], user),
pinned: pinned?(activity, user),
sensitive: sensitive,
- spoiler_text: object["summary"] || "",
+ spoiler_text: summary,
visibility: get_visibility(object),
media_attachments: attachments,
mentions: mentions,
language: nil,
emojis: build_emojis(activity.data["object"]["emoji"]),
pleroma: %{
- local: activity.local
+ local: activity.local,
+ conversation_id: get_context_id(activity)
}
}
end
preview_url: href,
text_url: href,
type: type,
- description: attachment["name"]
+ description: attachment["name"],
+ pleroma: %{mime_type: media_type}
}
end