Merge remote-tracking branch 'origin/develop' into fork

This commit is contained in:
marcin mikołajczak 2024-09-15 12:08:20 +02:00
commit 8c35794961
4 changed files with 20 additions and 0 deletions

View file

@ -0,0 +1 @@
Add `group_key` to notifications

View file

@ -157,6 +157,10 @@ def notification do
type: :object, type: :object,
properties: %{ properties: %{
id: %Schema{type: :string}, id: %Schema{type: :string},
group_key: %Schema{
type: :string,
description: "Group key shared by similar notifications"
},
type: notification_type(), type: notification_type(),
created_at: %Schema{type: :string, format: :"date-time"}, created_at: %Schema{type: :string, format: :"date-time"},
account: %Schema{ account: %Schema{
@ -184,6 +188,7 @@ def notification do
}, },
example: %{ example: %{
"id" => "34975861", "id" => "34975861",
"group-key" => "ungrouped-34975861",
"type" => "mention", "type" => "mention",
"created_at" => "2019-11-23T07:49:02.064Z", "created_at" => "2019-11-23T07:49:02.064Z",
"account" => Account.schema().example, "account" => Account.schema().example,

View file

@ -95,6 +95,7 @@ def render(
response = %{ response = %{
id: to_string(notification.id), id: to_string(notification.id),
group_key: "ungrouped-" <> to_string(notification.id),
type: notification.type, type: notification.type,
created_at: CommonAPI.Utils.to_masto_date(notification.inserted_at), created_at: CommonAPI.Utils.to_masto_date(notification.inserted_at),
account: account, account: account,

View file

@ -56,6 +56,7 @@ test "ChatMessage notification" do
expected = %{ expected = %{
id: to_string(notification.id), id: to_string(notification.id),
group_key: "ungrouped-#{to_string(notification.id)}",
pleroma: %{is_seen: false, is_muted: false}, pleroma: %{is_seen: false, is_muted: false},
type: "pleroma:chat_mention", type: "pleroma:chat_mention",
account: AccountView.render("show.json", %{user: user, for: recipient}), account: AccountView.render("show.json", %{user: user, for: recipient}),
@ -75,6 +76,7 @@ test "Mention notification" do
expected = %{ expected = %{
id: to_string(notification.id), id: to_string(notification.id),
group_key: "ungrouped-#{to_string(notification.id)}",
pleroma: %{is_seen: false, is_muted: false}, pleroma: %{is_seen: false, is_muted: false},
type: "mention", type: "mention",
account: account:
@ -99,6 +101,7 @@ test "Favourite notification" do
expected = %{ expected = %{
id: to_string(notification.id), id: to_string(notification.id),
group_key: "ungrouped-#{to_string(notification.id)}",
pleroma: %{is_seen: false, is_muted: false}, pleroma: %{is_seen: false, is_muted: false},
type: "favourite", type: "favourite",
account: AccountView.render("show.json", %{user: another_user, for: user}), account: AccountView.render("show.json", %{user: another_user, for: user}),
@ -119,6 +122,7 @@ test "Reblog notification" do
expected = %{ expected = %{
id: to_string(notification.id), id: to_string(notification.id),
group_key: "ungrouped-#{to_string(notification.id)}",
pleroma: %{is_seen: false, is_muted: false}, pleroma: %{is_seen: false, is_muted: false},
type: "reblog", type: "reblog",
account: AccountView.render("show.json", %{user: another_user, for: user}), account: AccountView.render("show.json", %{user: another_user, for: user}),
@ -137,6 +141,7 @@ test "Follow notification" do
expected = %{ expected = %{
id: to_string(notification.id), id: to_string(notification.id),
group_key: "ungrouped-#{to_string(notification.id)}",
pleroma: %{is_seen: false, is_muted: false}, pleroma: %{is_seen: false, is_muted: false},
type: "follow", type: "follow",
account: AccountView.render("show.json", %{user: follower, for: followed}), account: AccountView.render("show.json", %{user: follower, for: followed}),
@ -166,6 +171,7 @@ test "Move notification" do
expected = %{ expected = %{
id: to_string(notification.id), id: to_string(notification.id),
group_key: "ungrouped-#{to_string(notification.id)}",
pleroma: %{is_seen: false, is_muted: false}, pleroma: %{is_seen: false, is_muted: false},
type: "move", type: "move",
account: AccountView.render("show.json", %{user: old_user, for: follower}), account: AccountView.render("show.json", %{user: old_user, for: follower}),
@ -191,6 +197,7 @@ test "EmojiReact notification" do
expected = %{ expected = %{
id: to_string(notification.id), id: to_string(notification.id),
group_key: "ungrouped-#{to_string(notification.id)}",
pleroma: %{is_seen: false, is_muted: false}, pleroma: %{is_seen: false, is_muted: false},
type: "pleroma:emoji_reaction", type: "pleroma:emoji_reaction",
emoji: "", emoji: "",
@ -230,6 +237,7 @@ test "EmojiReact custom emoji notification" do
expected = %{ expected = %{
id: to_string(notification.id), id: to_string(notification.id),
group_key: "ungrouped-#{to_string(notification.id)}",
pleroma: %{is_seen: false, is_muted: false}, pleroma: %{is_seen: false, is_muted: false},
type: "pleroma:emoji_reaction", type: "pleroma:emoji_reaction",
emoji: ":dinosaur:", emoji: ":dinosaur:",
@ -249,6 +257,7 @@ test "Poll notification" do
expected = %{ expected = %{
id: to_string(notification.id), id: to_string(notification.id),
group_key: "ungrouped-#{to_string(notification.id)}",
pleroma: %{is_seen: false, is_muted: false}, pleroma: %{is_seen: false, is_muted: false},
type: "poll", type: "poll",
account: account:
@ -275,6 +284,7 @@ test "Report notification" do
expected = %{ expected = %{
id: to_string(notification.id), id: to_string(notification.id),
group_key: "ungrouped-#{to_string(notification.id)}",
pleroma: %{is_seen: false, is_muted: false}, pleroma: %{is_seen: false, is_muted: false},
type: "pleroma:report", type: "pleroma:report",
account: AccountView.render("show.json", %{user: reporting_user, for: moderator_user}), account: AccountView.render("show.json", %{user: reporting_user, for: moderator_user}),
@ -301,6 +311,7 @@ test "Edit notification" do
expected = %{ expected = %{
id: to_string(notification.id), id: to_string(notification.id),
group_key: "ungrouped-#{to_string(notification.id)}",
pleroma: %{is_seen: false, is_muted: false}, pleroma: %{is_seen: false, is_muted: false},
type: "update", type: "update",
account: AccountView.render("show.json", %{user: user, for: repeat_user}), account: AccountView.render("show.json", %{user: user, for: repeat_user}),
@ -323,6 +334,7 @@ test "muted notification" do
expected = %{ expected = %{
id: to_string(notification.id), id: to_string(notification.id),
group_key: "ungrouped-#{to_string(notification.id)}",
pleroma: %{is_seen: true, is_muted: true}, pleroma: %{is_seen: true, is_muted: true},
type: "favourite", type: "favourite",
account: AccountView.render("show.json", %{user: another_user, for: user}), account: AccountView.render("show.json", %{user: another_user, for: user}),
@ -346,6 +358,7 @@ test "Subscribed status notification" do
expected = %{ expected = %{
id: to_string(notification.id), id: to_string(notification.id),
group_key: "ungrouped-#{to_string(notification.id)}",
pleroma: %{is_seen: false, is_muted: false}, pleroma: %{is_seen: false, is_muted: false},
type: "status", type: "status",
account: account: