X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Ftwitter_api%2Fviews%2Factivity_view.ex;h=ad0cc76edf72adac00a899c19a7f6b052fec5e0d;hb=0b54c3d6432dea77542596e34057f8d3fc69ca4c;hp=4e4433aed5653e1186314473d3b7736dc2ec4422;hpb=b3b7ab5d9a0528bdfa385bd61d7f97ae4c7de374;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 4e4433aed..ad0cc76ed 100644
--- a/lib/pleroma/web/twitter_api/views/activity_view.ex
+++ b/lib/pleroma/web/twitter_api/views/activity_view.ex
@@ -1,3 +1,7 @@
+# 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)
%{
"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,
@@ -262,7 +287,48 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
"external_url" => object["external_url"] || object["id"],
"tags" => tags,
"activity_type" => "post",
- "possibly_sensitive" => possibly_sensitive
+ "possibly_sensitive" => possibly_sensitive,
+ "visibility" => Pleroma.Web.MastodonAPI.StatusView.get_visibility(object),
+ "summary" => HTML.strip_tags(summary) |> Formatter.emojify(object["emoji"])
}
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