X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=inline;f=lib%2Fpleroma%2Fweb%2Ftwitter_api%2Frepresenters%2Factivity_representer.ex;h=73ae3422bb260d410e3f3c5f30275af7dea8e5c1;hb=df8fc7249103fc1fdb574463201f02f4c99f9bec;hp=929e26bf0ff1dfe3bb0f40bce37ab26e1ff54f07;hpb=959e993c7d112d9a30baae3d403687903a7f6a27;p=akkoma diff --git a/lib/pleroma/web/twitter_api/representers/activity_representer.ex b/lib/pleroma/web/twitter_api/representers/activity_representer.ex index 929e26bf0..73ae3422b 100644 --- a/lib/pleroma/web/twitter_api/representers/activity_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/activity_representer.ex @@ -56,7 +56,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do } end - def to_map(%Activity{data: %{"type" => "Follow", "published" => created_at, "object" => followed_id}} = activity, %{user: user} = opts) do + def to_map(%Activity{data: %{"type" => "Follow", "object" => followed_id}} = activity, %{user: user} = opts) do + created_at = activity.data["published"] || (DateTime.to_iso8601(activity.inserted_at)) created_at = created_at |> Utils.date_to_asctime followed = User.get_cached_by_ap_id(followed_id) @@ -97,7 +98,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do } end - def to_map(%Activity{data: %{"type" => "Delete", "published" => created_at, "object" => deleted_object }} = activity, %{user: user} = opts) do + def to_map(%Activity{data: %{"type" => "Delete", "published" => created_at, "object" => _ }} = activity, %{user: user} = opts) do created_at = created_at |> Utils.date_to_asctime %{ @@ -125,7 +126,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do mentions = opts[:mentioned] || [] - attentions = activity.data["to"] + attentions = activity.recipients |> Enum.map(fn (ap_id) -> Enum.find(mentions, fn(user) -> ap_id == user.ap_id end) end) |> Enum.filter(&(&1)) |> Enum.map(fn (user) -> UserView.render("show.json", %{user: user, for: opts[:for]}) end) @@ -133,9 +134,19 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do conversation_id = conversation_id(activity) tags = activity.data["object"]["tag"] || [] - possibly_sensitive = Enum.member?(tags, "nsfw") + possibly_sensitive = activity.data["object"]["sensitive"] || Enum.member?(tags, "nsfw") - html = HtmlSanitizeEx.basic_html(content) |> Formatter.emojify(object["emoji"]) + tags = if possibly_sensitive, do: Enum.uniq(["nsfw" | tags]), else: tags + + summary = activity.data["object"]["summary"] + content = if !!summary and summary != "" do + "#{activity.data["object"]["summary"]}
#{content}" + else + content + end + + html = HtmlSanitizeEx.basic_html(content) + |> Formatter.emojify(object["emoji"]) %{ "id" => activity.id, @@ -154,7 +165,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do "repeat_num" => announcement_count, "favorited" => to_boolean(favorited), "repeated" => to_boolean(repeated), - "external_url" => object["external_url"], + "external_url" => object["external_url"] || object["id"], "tags" => tags, "activity_type" => "post", "possibly_sensitive" => possibly_sensitive