1 defmodule Pleroma.Web.TwitterAPI.NotificationView do
3 alias Pleroma.{Notification, User}
4 alias Pleroma.Web.CommonAPI.Utils
5 alias Pleroma.Web.MediaProxy
6 alias Pleroma.Web.TwitterAPI.UserView
7 alias Pleroma.Web.TwitterAPI.ActivityView
9 defp get_user(ap_id, opts) do
11 user = opts[:users][ap_id] ->
14 String.ends_with?(ap_id, "/followers") ->
17 ap_id == "https://www.w3.org/ns/activitystreams#Public" ->
21 User.get_cached_by_ap_id(ap_id)
25 def render("notification.json", %{notifications: notifications, for: user}) do
28 Pleroma.Web.TwitterAPI.NotificationView,
37 notification: %Notification{
41 inserted_at: created_at
47 case activity.data["type"] do
50 "Announce" -> "repeat"
54 from = get_user(activity.data["actor"], opts)
59 "notice" => ActivityView.render("activity.json", %{activity: activity, for: user}),
60 "from_profile" => UserView.render("show.json", %{user: from, for: user}),
61 "is_seen" => if(seen, do: 1, else: 0),
62 "created_at" => created_at |> Utils.format_naive_asctime()