1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.MastodonAPI.SubscriptionNotificationView do
10 alias Pleroma.Web.CommonAPI
11 alias Pleroma.Web.MastodonAPI.AccountView
12 alias Pleroma.Web.MastodonAPI.SubscriptionNotificationView
13 alias Pleroma.Web.MastodonAPI.StatusView
15 def render("index.json", %{notifications: notifications, for: user}) do
16 safe_render_many(notifications, SubscriptionNotificationView, "show.json", %{for: user})
19 def render("show.json", %{
20 subscription_notification: %{activity: activity} = notification,
23 actor = User.get_cached_by_ap_id(activity.data["actor"])
24 parent_activity = Activity.get_create_by_object_ap_id(activity.data["object"])
25 mastodon_type = Activity.mastodon_notification_type(activity)
28 id: to_string(notification.id),
30 created_at: CommonAPI.Utils.to_masto_date(notification.inserted_at),
31 account: AccountView.render("account.json", %{user: actor, for: user})
38 status: StatusView.render("status.json", %{activity: activity, for: user})
44 status: StatusView.render("status.json", %{activity: parent_activity, for: user})
50 status: StatusView.render("status.json", %{activity: parent_activity, for: user})