diff options
author | kaniini <ariadne@dereferenced.org> | 2019-10-04 22:37:45 +0000 |
---|---|---|
committer | kaniini <ariadne@dereferenced.org> | 2019-10-04 22:37:45 +0000 |
commit | 4168ead67290fce809c8c7bf671fd9de07079da6 (patch) | |
tree | 1af830857b44e852359bdc53c876cadf2e346317 /lib | |
parent | 43be47c16136363506fda9e013df5ea19a5cb0e5 (diff) | |
parent | 2714caac8b275bf2e75285e358ccb3818133854a (diff) | |
download | pleroma-4168ead67290fce809c8c7bf671fd9de07079da6.tar.gz pleroma-4168ead67290fce809c8c7bf671fd9de07079da6.zip |
Merge branch 'backport/bugfix-notification-nil-actor' into 'maint/1.1'
backport MR 1779 to maint/1.1
See merge request pleroma/pleroma!1791
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/notification_view.ex | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/notification_view.ex b/lib/pleroma/web/mastodon_api/views/notification_view.ex index ec8eadcaa..eb9ca1b04 100644 --- a/lib/pleroma/web/mastodon_api/views/notification_view.ex +++ b/lib/pleroma/web/mastodon_api/views/notification_view.ex @@ -25,40 +25,44 @@ defmodule Pleroma.Web.MastodonAPI.NotificationView do parent_activity = Activity.get_create_by_object_ap_id(activity.data["object"]) mastodon_type = Activity.mastodon_notification_type(activity) - response = %{ - id: to_string(notification.id), - type: mastodon_type, - created_at: CommonAPI.Utils.to_masto_date(notification.inserted_at), - account: AccountView.render("account.json", %{user: actor, for: user}), - pleroma: %{ - is_seen: notification.seen + with %{id: _} = account <- AccountView.render("account.json", %{user: actor, for: user}) do + response = %{ + id: to_string(notification.id), + type: mastodon_type, + created_at: CommonAPI.Utils.to_masto_date(notification.inserted_at), + account: account, + pleroma: %{ + is_seen: notification.seen + } } - } - case mastodon_type do - "mention" -> - response - |> Map.merge(%{ - status: StatusView.render("status.json", %{activity: activity, for: user}) - }) + case mastodon_type do + "mention" -> + response + |> Map.merge(%{ + status: StatusView.render("status.json", %{activity: activity, for: user}) + }) - "favourite" -> - response - |> Map.merge(%{ - status: StatusView.render("status.json", %{activity: parent_activity, for: user}) - }) + "favourite" -> + response + |> Map.merge(%{ + status: StatusView.render("status.json", %{activity: parent_activity, for: user}) + }) - "reblog" -> - response - |> Map.merge(%{ - status: StatusView.render("status.json", %{activity: parent_activity, for: user}) - }) + "reblog" -> + response + |> Map.merge(%{ + status: StatusView.render("status.json", %{activity: parent_activity, for: user}) + }) - "follow" -> - response + "follow" -> + response - _ -> - nil + _ -> + nil + end + else + _ -> nil end end end |