|
|
@ -25,40 +25,44 @@ defmodule Pleroma.Web.MastodonAPI.NotificationView do
|
|
|
|
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("show.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("show.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("show.json", %{activity: activity, for: user})
|
|
|
|
status: StatusView.render("show.json", %{activity: activity, for: user})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
"favourite" ->
|
|
|
|
"favourite" ->
|
|
|
|
response
|
|
|
|
response
|
|
|
|
|> Map.merge(%{
|
|
|
|
|> Map.merge(%{
|
|
|
|
status: StatusView.render("show.json", %{activity: parent_activity, for: user})
|
|
|
|
status: StatusView.render("show.json", %{activity: parent_activity, for: user})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
"reblog" ->
|
|
|
|
"reblog" ->
|
|
|
|
response
|
|
|
|
response
|
|
|
|
|> Map.merge(%{
|
|
|
|
|> Map.merge(%{
|
|
|
|
status: StatusView.render("show.json", %{activity: parent_activity, for: user})
|
|
|
|
status: StatusView.render("show.json", %{activity: parent_activity, for: user})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
"follow" ->
|
|
|
|
"follow" ->
|
|
|
|
response
|
|
|
|
response
|
|
|
|
|
|
|
|
|
|
|
|
_ ->
|
|
|
|
_ ->
|
|
|
|
nil
|
|
|
|
nil
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
_ -> nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|