notification_view.ex: Make sure `account` isn’t empty
Related: https://git.pleroma.social/pleroma/pleroma/issues/1203
This commit is contained in:
parent
43be47c161
commit
dbd78de176
|
@ -25,11 +25,12 @@ def render("show.json", %{
|
||||||
parent_activity = Activity.get_create_by_object_ap_id(activity.data["object"])
|
parent_activity = Activity.get_create_by_object_ap_id(activity.data["object"])
|
||||||
mastodon_type = Activity.mastodon_notification_type(activity)
|
mastodon_type = Activity.mastodon_notification_type(activity)
|
||||||
|
|
||||||
|
with %{id: _} = account <- AccountView.render("account.json", %{user: actor, for: user}) do
|
||||||
response = %{
|
response = %{
|
||||||
id: to_string(notification.id),
|
id: to_string(notification.id),
|
||||||
type: mastodon_type,
|
type: mastodon_type,
|
||||||
created_at: CommonAPI.Utils.to_masto_date(notification.inserted_at),
|
created_at: CommonAPI.Utils.to_masto_date(notification.inserted_at),
|
||||||
account: AccountView.render("account.json", %{user: actor, for: user}),
|
account: account,
|
||||||
pleroma: %{
|
pleroma: %{
|
||||||
is_seen: notification.seen
|
is_seen: notification.seen
|
||||||
}
|
}
|
||||||
|
@ -60,5 +61,8 @@ def render("show.json", %{
|
||||||
_ ->
|
_ ->
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
_ -> nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -100,5 +100,11 @@ test "Follow notification" do
|
||||||
NotificationView.render("index.json", %{notifications: [notification], for: followed})
|
NotificationView.render("index.json", %{notifications: [notification], for: followed})
|
||||||
|
|
||||||
assert [expected] == result
|
assert [expected] == result
|
||||||
|
|
||||||
|
User.perform(:delete, follower)
|
||||||
|
notification = Notification |> Repo.one() |> Repo.preload(:activity)
|
||||||
|
|
||||||
|
assert [] ==
|
||||||
|
NotificationView.render("index.json", %{notifications: [notification], for: followed})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue