1 defmodule Pleroma.Web.TwitterAPI.NotificationView do
3 alias Pleroma.{Notification, User}
4 alias Pleroma.Web.CommonAPI.Utils
5 alias Pleroma.Web.TwitterAPI.UserView
6 alias Pleroma.Web.TwitterAPI.ActivityView
8 defp get_user(ap_id, opts) do
10 user = opts[:users][ap_id] ->
13 String.ends_with?(ap_id, "/followers") ->
16 ap_id == "https://www.w3.org/ns/activitystreams#Public" ->
20 User.get_cached_by_ap_id(ap_id)
24 def render("notification.json", %{notifications: notifications, for: user}) do
27 Pleroma.Web.TwitterAPI.NotificationView,
36 notification: %Notification{
40 inserted_at: created_at
46 case activity.data["type"] do
49 "Announce" -> "repeat"
53 from = get_user(activity.data["actor"], opts)
58 "notice" => ActivityView.render("activity.json", %{activity: activity, for: user}),
59 "from_profile" => UserView.render("show.json", %{user: from, for: user}),
60 "is_seen" => if(seen, do: 1, else: 0),
61 "created_at" => created_at |> Utils.format_naive_asctime()