Merge branch 'backport/bugfix-notification-nil-actor' into 'maint/1.1'
backport MR 1779 to maint/1.1 See merge request pleroma/pleroma!1791
This commit is contained in:
commit
4168ead672
@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- Mastodon API: Inability to get some local users by nickname in `/api/v1/accounts/:id_or_nickname`
|
- Mastodon API: Inability to get some local users by nickname in `/api/v1/accounts/:id_or_nickname`
|
||||||
- Mastodon API: Blocks are now treated consistently between the Streaming API and the Timeline APIs
|
- Mastodon API: Blocks are now treated consistently between the Streaming API and the Timeline APIs
|
||||||
- ActivityPub: Correct addressing of Undo.
|
- ActivityPub: Correct addressing of Undo.
|
||||||
|
- Mastodon API: Ensure the `account` field is not empty when rendering Notification entities.
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- ActivityPub: The `/objects/:uuid/likes` endpoint.
|
- ActivityPub: The `/objects/:uuid/likes` endpoint.
|
||||||
|
@ -25,40 +25,44 @@ 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)
|
||||||
|
|
||||||
response = %{
|
with %{id: _} = account <- AccountView.render("account.json", %{user: actor, for: user}) do
|
||||||
id: to_string(notification.id),
|
response = %{
|
||||||
type: mastodon_type,
|
id: to_string(notification.id),
|
||||||
created_at: CommonAPI.Utils.to_masto_date(notification.inserted_at),
|
type: mastodon_type,
|
||||||
account: AccountView.render("account.json", %{user: actor, for: user}),
|
created_at: CommonAPI.Utils.to_masto_date(notification.inserted_at),
|
||||||
pleroma: %{
|
account: account,
|
||||||
is_seen: notification.seen
|
pleroma: %{
|
||||||
|
is_seen: notification.seen
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
case mastodon_type do
|
case mastodon_type do
|
||||||
"mention" ->
|
"mention" ->
|
||||||
response
|
response
|
||||||
|> Map.merge(%{
|
|> Map.merge(%{
|
||||||
status: StatusView.render("status.json", %{activity: activity, for: user})
|
status: StatusView.render("status.json", %{activity: activity, for: user})
|
||||||
})
|
})
|
||||||
|
|
||||||
"favourite" ->
|
"favourite" ->
|
||||||
response
|
response
|
||||||
|> Map.merge(%{
|
|> Map.merge(%{
|
||||||
status: StatusView.render("status.json", %{activity: parent_activity, for: user})
|
status: StatusView.render("status.json", %{activity: parent_activity, for: user})
|
||||||
})
|
})
|
||||||
|
|
||||||
"reblog" ->
|
"reblog" ->
|
||||||
response
|
response
|
||||||
|> Map.merge(%{
|
|> Map.merge(%{
|
||||||
status: StatusView.render("status.json", %{activity: parent_activity, for: user})
|
status: StatusView.render("status.json", %{activity: parent_activity, for: user})
|
||||||
})
|
})
|
||||||
|
|
||||||
"follow" ->
|
"follow" ->
|
||||||
response
|
response
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
nil
|
nil
|
||||||
|
end
|
||||||
|
else
|
||||||
|
_ -> nil
|
||||||
end
|
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
Block a user