X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Ftwitter_api%2Fviews%2Factivity_view.ex;h=83e8fb765b3d4a3cd1a735763b3cfd467258d372;hb=6c8d15da110e86f799052c82df8b7b2404f8f722;hp=580d4648cfd59f3d7bdea948faf73ad8e89bc31d;hpb=955bd643ff4a1a2e840b10b14d4ed0593aa9f025;p=akkoma
diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex
index 580d4648c..661022afa 100644
--- a/lib/pleroma/web/twitter_api/views/activity_view.ex
+++ b/lib/pleroma/web/twitter_api/views/activity_view.ex
@@ -1,18 +1,24 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors
#{content}"
- else
+ html =
+ content
+ |> HTML.get_cached_scrubbed_html_for_object(
+ User.html_filter_policy(opts[:for]),
+ activity,
+ __MODULE__
+ )
+ |> Formatter.emojify(object["emoji"])
+
+ text =
+ if content do
content
+ |> String.replace(~r/
/, "\n")
+ |> HTML.get_cached_stripped_html_for_object(activity, __MODULE__)
end
- html =
- HtmlSanitizeEx.basic_html(content)
- |> Formatter.emojify(object["emoji"])
+ reply_parent = Activity.get_in_reply_to_activity(activity)
+
+ reply_user = reply_parent && User.get_cached_by_ap_id(reply_parent.actor)
+
+ summary = HTML.strip_tags(summary)
+
+ card =
+ StatusView.render(
+ "card.json",
+ Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity)
+ )
%{
"id" => activity.id,
"uri" => activity.data["object"]["id"],
"user" => UserView.render("show.json", %{user: user, for: opts[:for]}),
"statusnet_html" => html,
- "text" => HtmlSanitizeEx.strip_tags(content),
+ "text" => text,
"is_local" => activity.local,
"is_post_verb" => true,
"created_at" => created_at,
"in_reply_to_status_id" => object["inReplyToStatusId"],
+ "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,
@@ -259,10 +301,54 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
"repeat_num" => announcement_count,
"favorited" => !!favorited,
"repeated" => !!repeated,
+ "pinned" => pinned,
"external_url" => object["external_url"] || object["id"],
"tags" => tags,
"activity_type" => "post",
- "possibly_sensitive" => possibly_sensitive
+ "possibly_sensitive" => possibly_sensitive,
+ "visibility" => StatusView.get_visibility(object),
+ "summary" => summary,
+ "summary_html" => summary |> Formatter.emojify(object["emoji"]),
+ "card" => card
}
end
+
+ def render("activity.json", %{activity: unhandled_activity}) do
+ Logger.warn("#{__MODULE__} unhandled activity: #{inspect(unhandled_activity)}")
+ nil
+ end
+
+ def render_content(%{"type" => "Note"} = object) do
+ summary = object["summary"]
+
+ content =
+ if !!summary and summary != "" do
+ "
#{summary}
#{object["content"]}" + else + object["content"] + end + + {summary, content} + end + + def render_content(%{"type" => object_type} = object) + when object_type in ["Article", "Page", "Video"] do + summary = object["name"] || object["summary"] + + content = + if !!summary and summary != "" and is_bitstring(object["url"]) do + "#{object["content"]}" + else + object["content"] + end + + {summary, content} + end + + def render_content(object) do + summary = object["summary"] || "Unhandled activity type: #{object["type"]}" + content = "#{summary}
#{object["content"]}" + + {summary, content} + end end