X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fmastodon_api%2Fviews%2Fnotification_view.ex;h=33145c484d6f74fe03e95a88292ebd9cb58d2bc1;hb=4c02e049358441529c54a72cd11f1c81ee897d49;hp=5e3dbe728335d09dbd70b641bcb22c0e63349dc6;hpb=91e90aa807c2ce346cd453201447806fb71b21fe;p=akkoma diff --git a/lib/pleroma/web/mastodon_api/views/notification_view.ex b/lib/pleroma/web/mastodon_api/views/notification_view.ex index 5e3dbe728..33145c484 100644 --- a/lib/pleroma/web/mastodon_api/views/notification_view.ex +++ b/lib/pleroma/web/mastodon_api/views/notification_view.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2019 Pleroma Authors +# Copyright © 2017-2020 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.MastodonAPI.NotificationView do @@ -38,26 +38,23 @@ defmodule Pleroma.Web.MastodonAPI.NotificationView do case mastodon_type do "mention" -> - response - |> Map.merge(%{ - status: StatusView.render("show.json", %{activity: activity, for: user}) - }) + put_status(response, activity, user) "favourite" -> - response - |> Map.merge(%{ - status: StatusView.render("show.json", %{activity: parent_activity, for: user}) - }) + put_status(response, parent_activity, user) "reblog" -> - response - |> Map.merge(%{ - status: StatusView.render("show.json", %{activity: parent_activity, for: user}) - }) + put_status(response, parent_activity, user) + + "move" -> + put_target(response, activity, user) "follow" -> response + "pleroma:emoji_reaction" -> + put_status(response, parent_activity, user) |> put_emoji(activity) + _ -> nil end @@ -65,4 +62,18 @@ defmodule Pleroma.Web.MastodonAPI.NotificationView do _ -> nil end end + + defp put_emoji(response, activity) do + response + |> Map.put(:emoji, activity.data["content"]) + end + + defp put_status(response, activity, user) do + Map.put(response, :status, StatusView.render("show.json", %{activity: activity, for: user})) + end + + defp put_target(response, activity, user) do + target = User.get_cached_by_ap_id(activity.data["target"]) + Map.put(response, :target, AccountView.render("show.json", %{user: target, for: user})) + end end