Merge remote-tracking branch 'parent/main' into upstream-20240830

This commit is contained in:
KMY 2024-08-30 08:17:34 +09:00
commit 206021455e
25 changed files with 378 additions and 144 deletions

View file

@ -42,7 +42,7 @@ class Api::V2Alpha::NotificationsController < Api::BaseController
limit = limit_param(DEFAULT_NOTIFICATIONS_COUNT_LIMIT, MAX_NOTIFICATIONS_COUNT_LIMIT)
with_read_replica do
render json: { count: browserable_account_notifications.paginate_groups_by_min_id(limit, min_id: notification_marker&.last_read_id).count }
render json: { count: browserable_account_notifications.paginate_groups_by_min_id(limit, min_id: notification_marker&.last_read_id, grouped_types: params[:grouped_types]).count }
end
end
@ -68,7 +68,7 @@ class Api::V2Alpha::NotificationsController < Api::BaseController
MastodonOTELTracer.in_span('Api::V2Alpha::NotificationsController#load_notifications') do
notifications = browserable_account_notifications.includes(from_account: [:account_stat, :user]).to_a_grouped_paginated_by_id(
limit_param(DEFAULT_NOTIFICATIONS_LIMIT),
params_slice(:max_id, :since_id, :min_id)
params.slice(:max_id, :since_id, :min_id, :grouped_types).permit(:max_id, :since_id, :min_id, grouped_types: [])
)
Notification.preload_cache_collection_target_statuses(notifications) do |target_statuses|
@ -92,7 +92,7 @@ class Api::V2Alpha::NotificationsController < Api::BaseController
def load_grouped_notifications
MastodonOTELTracer.in_span('Api::V2Alpha::NotificationsController#load_grouped_notifications') do
@notifications.map { |notification| NotificationGroup.from_notification(notification, max_id: @group_metadata.dig(notification.group_key, :max_id)) }
@notifications.map { |notification| NotificationGroup.from_notification(notification, max_id: @group_metadata.dig(notification.group_key, :max_id), grouped_types: params[:grouped_types]) }
end
end
@ -125,11 +125,11 @@ class Api::V2Alpha::NotificationsController < Api::BaseController
end
def browserable_params
params.permit(:include_filtered, types: [], exclude_types: [])
params.slice(:include_filtered, :types, :exclude_types, :grouped_types).permit(:include_filtered, types: [], exclude_types: [], grouped_types: [])
end
def pagination_params(core_params)
params.slice(:limit, :types, :exclude_types, :include_filtered).permit(:limit, :include_filtered, types: [], exclude_types: []).merge(core_params)
params.slice(:limit, :include_filtered, :types, :exclude_types, :grouped_types).permit(:limit, :include_filtered, types: [], exclude_types: [], grouped_types: []).merge(core_params)
end
def expand_accounts_param

View file

@ -97,6 +97,8 @@
"block_modal.title": "Zablokovat uživatele?",
"block_modal.you_wont_see_mentions": "Neuvidíte příspěvky, které ho zmiňují.",
"boost_modal.combo": "Příště můžete pro přeskočení stisknout {combo}",
"boost_modal.reblog": "Boostnout příspěvek?",
"boost_modal.undo_reblog": "Zrušit boostování příspěvku?",
"bundle_column_error.copy_stacktrace": "Zkopírovat zprávu o chybě",
"bundle_column_error.error.body": "Požadovanou stránku nelze vykreslit. Může to být způsobeno chybou v našem kódu nebo problémem s kompatibilitou prohlížeče.",
"bundle_column_error.error.title": "Ale ne!",
@ -192,6 +194,7 @@
"confirmations.unfollow.confirm": "Přestat sledovat",
"confirmations.unfollow.message": "Opravdu chcete {name} přestat sledovat?",
"confirmations.unfollow.title": "Přestat sledovat uživatele?",
"content_warning.hide": "Skrýt příspěvek",
"conversation.delete": "Smazat konverzaci",
"conversation.mark_as_read": "Označit jako přečtené",
"conversation.open": "Zobrazit konverzaci",

View file

@ -97,6 +97,8 @@
"block_modal.title": "Erabiltzailea blokeatu nahi duzu?",
"block_modal.you_wont_see_mentions": "Ez duzu ikusiko bera aipatzen duen argitalpenik.",
"boost_modal.combo": "{combo} sakatu dezakezu hurrengoan hau saltatzeko",
"boost_modal.reblog": "Bultzatu bidalketa?",
"boost_modal.undo_reblog": "Bidalketari bultzada kendu?",
"bundle_column_error.copy_stacktrace": "Kopiatu errore-txostena",
"bundle_column_error.error.body": "Eskatutako orria ezin izan da bistaratu. Kodeko errore bategatik izan daiteke edo nabigatzailearen bateragarritasun arazo bategatik.",
"bundle_column_error.error.title": "O ez!",
@ -192,6 +194,8 @@
"confirmations.unfollow.confirm": "Utzi jarraitzeari",
"confirmations.unfollow.message": "Ziur {name} jarraitzeari utzi nahi diozula?",
"confirmations.unfollow.title": "Erabiltzailea jarraitzeari utzi?",
"content_warning.hide": "Tuta ezkutatu",
"content_warning.show": "Erakutsi hala ere",
"conversation.delete": "Ezabatu elkarrizketa",
"conversation.mark_as_read": "Markatu irakurrita bezala",
"conversation.open": "Ikusi elkarrizketa",
@ -299,6 +303,8 @@
"filter_modal.select_filter.subtitle": "Hautatu lehendik dagoen kategoria bat edo sortu berria",
"filter_modal.select_filter.title": "Iragazi bidalketa hau",
"filter_modal.title.status": "Iragazi bidalketa bat",
"filter_warning.matches_filter": "“{title}” iragazkiarekin bat dator",
"filtered_notifications_banner.pending_requests": "Ezagutu dezakezun {count, plural, =0 {inoren} one {pertsona baten} other {# pertsonen}}",
"filtered_notifications_banner.title": "Iragazitako jakinarazpenak",
"firehose.all": "Guztiak",
"firehose.local": "Zerbitzari hau",
@ -347,6 +353,14 @@
"hashtag.follow": "Jarraitu traolari",
"hashtag.unfollow": "Utzi traola jarraitzeari",
"hashtags.and_other": "…eta {count, plural, one {}other {# gehiago}}",
"hints.profiles.followers_may_be_missing": "Baliteke profil honen jarraitzaile guztiak ez agertzea.",
"hints.profiles.follows_may_be_missing": "Baliteke profil honek jarraitzen dituen profil guztiak ez erakustea.",
"hints.profiles.posts_may_be_missing": "Baliteke profil honen tut guztiak ez erakustea.",
"hints.profiles.see_more_followers": "Ikusi jarraitzaile gehiago {domain}-(e)n",
"hints.profiles.see_more_follows": "Ikusi jarraitzaile gehiago {domain}-(e)n",
"hints.profiles.see_more_posts": "Ikusi bidalketa gehiago {domain}-(e)n",
"hints.threads.replies_may_be_missing": "Baliteke beste zerbitzari batzuen erantzun batzuk ez erakustea.",
"hints.threads.see_more": "Ikusi erantzun gehiago {domain}-(e)n",
"home.column_settings.show_reblogs": "Erakutsi bultzadak",
"home.column_settings.show_replies": "Erakutsi erantzunak",
"home.hide_announcements": "Ezkutatu iragarpenak",
@ -354,12 +368,17 @@
"home.pending_critical_update.link": "Ikusi eguneraketak",
"home.pending_critical_update.title": "Segurtasun eguneraketa kritikoa eskuragarri!",
"home.show_announcements": "Erakutsi iragarpenak",
"ignore_notifications_modal.disclaimer": "Mastodonek ezin die jakinarazi erabiltzaileei beraien jakinarazpenei ezikusiarena egingo diezula. Jakinarazpenei ezikusiarena egiteak ez du eragotziko mezuak bidaltzen jarraitzea.",
"ignore_notifications_modal.filter_instead": "Iragazi ez ikusiarena egin beharrean",
"ignore_notifications_modal.filter_to_act_users": "Oraindik ere erabiltzaileak onartu, baztertu edo salatu ahal izango dituzu",
"ignore_notifications_modal.filter_to_avoid_confusion": "Iragazteak nahaste potentzialak saihesten laguntzen du",
"ignore_notifications_modal.filter_to_review_separately": "Banaka berrikus ditzakezu iragazitako jakinarazpenak",
"ignore_notifications_modal.ignore": "Ezikusi jakinarazpenak",
"ignore_notifications_modal.limited_accounts_title": "Moderatutako kontuen jakinarazpenei ez ikusiarena egin?",
"ignore_notifications_modal.new_accounts_title": "Kontu berrien jakinarazpenei ez ikusiarena egin?",
"ignore_notifications_modal.not_followers_title": "Jarraitzen ez zaituzten pertsonen jakinarazpenei ez ikusiarena egin?",
"ignore_notifications_modal.not_following_title": "Jarraitzen ez dituzun pertsonen jakinarazpenei ez ikusiarena egin?",
"ignore_notifications_modal.private_mentions_title": "Eskatu gabeko aipamen pribatuen jakinarazpenei ez ikusiarena egin?",
"interaction_modal.description.favourite": "Mastodon kontu batekin bidalketa hau gogoko egin dezakezu, egileari eskertzeko eta gerorako gordetzeko.",
"interaction_modal.description.follow": "Mastodon kontu batekin {name} jarraitu dezakezu bere bidalketak zure hasierako denbora lerroan jasotzeko.",
"interaction_modal.description.reblog": "Mastodon kontu batekin bidalketa hau bultzatu dezakezu, zure jarraitzaileekin partekatzeko.",
@ -420,6 +439,8 @@
"limited_account_hint.action": "Erakutsi profila hala ere",
"limited_account_hint.title": "Profil hau ezkutatu egin dute {domain} zerbitzariko moderatzaileek.",
"link_preview.author": "Egilea: {name}",
"link_preview.more_from_author": "{name} erabiltzaileaz gehiago jakin",
"link_preview.shares": "{count, plural, one {{counter} bidalketa} other {{counter} bidalketa}}",
"lists.account.add": "Gehitu zerrendara",
"lists.account.remove": "Kendu zerrendatik",
"lists.delete": "Ezabatu zerrenda",
@ -448,6 +469,7 @@
"mute_modal.you_wont_see_mentions": "Ez duzu ikusiko bera aipatzen duen argitalpenik.",
"mute_modal.you_wont_see_posts": "Zure argitalpenak ikus ditzake, baina ez dituzu bereak ikusiko.",
"navigation_bar.about": "Honi buruz",
"navigation_bar.administration": "Administrazioa",
"navigation_bar.advanced_interface": "Ireki web interfaze aurreratuan",
"navigation_bar.blocks": "Blokeatutako erabiltzaileak",
"navigation_bar.bookmarks": "Laster-markak",
@ -464,6 +486,7 @@
"navigation_bar.follows_and_followers": "Jarraitutakoak eta jarraitzaileak",
"navigation_bar.lists": "Zerrendak",
"navigation_bar.logout": "Amaitu saioa",
"navigation_bar.moderation": "Moderazioa",
"navigation_bar.mutes": "Mutututako erabiltzaileak",
"navigation_bar.opened_in_classic_interface": "Argitalpenak, kontuak eta beste orri jakin batzuk lehenespenez irekitzen dira web-interfaze klasikoan.",
"navigation_bar.personal": "Pertsonala",
@ -474,10 +497,18 @@
"navigation_bar.security": "Segurtasuna",
"not_signed_in_indicator.not_signed_in": "Baliabide honetara sarbidea izateko saioa hasi behar duzu.",
"notification.admin.report": "{name} erabiltzaileak {target} salatu du",
"notification.admin.report_account": "{name}-(e)k {target}-ren {count, plural, one {bidalketa bat} other {# bidalketa}} salatu zituen {category} delakoagatik",
"notification.admin.report_account_other": "{name}-(e)k {target}-ren {count, plural, one {bidalketa bat salatu zuen} other {# bidalketa salatu zituen}}",
"notification.admin.report_statuses": "{name}-(e)k {target} salatu zuen {category} delakoagatik",
"notification.admin.report_statuses_other": "{name} erabiltzaileak {target} salatu du",
"notification.admin.sign_up": "{name} erabiltzailea erregistratu da",
"notification.admin.sign_up.name_and_others": "{name} eta {count, plural, one {erabiltzaile # gehiago} other {# erabiltzaile gehiago}} erregistratu dira",
"notification.favourite": "{name}(e)k zure bidalketa gogoko du",
"notification.favourite.name_and_others_with_link": "{name} eta <a>{count, plural, one {erabiltzaile # gehiagok} other {# erabiltzaile gehiagok}}</a> zure bidalketa gogoko dute",
"notification.follow": "{name}(e)k jarraitzen dizu",
"notification.follow.name_and_others": "{name} eta {count, plural, one {erabiltzaile # gehiagok} other {# erabiltzaile gehiagok}} jarraitu dizute",
"notification.follow_request": "{name}(e)k zu jarraitzeko eskaera egin du",
"notification.follow_request.name_and_others": "{name} eta {count, plural, one {erabiltzaile # gehiagok} other {# erabiltzaile gehiagok}} zu jarraitzeko eskaera egin dute",
"notification.label.mention": "Aipamena",
"notification.label.private_mention": "Aipamen pribatua",
"notification.label.private_reply": "Erantzun pribatua",
@ -495,14 +526,26 @@
"notification.own_poll": "Zure inkesta amaitu da",
"notification.poll": "Zuk erantzun duzun inkesta bat bukatu da",
"notification.reblog": "{name}(e)k bultzada eman dio zure bidalketari",
"notification.reblog.name_and_others_with_link": "{name} eta <a>{count, plural, one {erabiltzaile # gehiagok} other {# erabiltzaile gehiagok}}</a> bultzada eman diote zure bidalketari",
"notification.relationships_severance_event": "{name} erabiltzailearekin galdutako konexioak",
"notification.relationships_severance_event.account_suspension": "{from} zerbitzariko administratzaile batek {target} bertan behera utzi du, hau da, ezin izango dituzu jaso hango eguneratzerik edo hangoekin elkarreragin.",
"notification.relationships_severance_event.learn_more": "Informazio gehiago",
"notification.status": "{name} erabiltzaileak bidalketa egin berri du",
"notification.update": "{name} erabiltzaileak bidalketa bat editatu du",
"notification_requests.accept": "Onartu",
"notification_requests.accept_multiple": "{count, plural, one {Onartu eskaera…} other {Onartu # eskaerak…}}",
"notification_requests.confirm_accept_multiple.button": "{count, plural, one {Onartu eskaera} other {Onartu eskaerak}}",
"notification_requests.confirm_accept_multiple.title": "Onartu jakinarazpen-eskaerak?",
"notification_requests.confirm_dismiss_multiple.button": "{count, plural, one {Baztertu eskaera} other {Baztertu eskaerak}}",
"notification_requests.confirm_dismiss_multiple.title": "Baztertu jakinarazpen-eskaerak?",
"notification_requests.dismiss": "Baztertu",
"notification_requests.dismiss_multiple": "{count, plural, one {Baztertu eskaera…} other {Baztertu # eskaerak…}}",
"notification_requests.edit_selection": "Editatu",
"notification_requests.exit_selection": "Egina",
"notification_requests.explainer_for_limited_account": "Kontu honen jakinarazpenak iragazi egin dira, kontua moderatzaile batek mugatu duelako.",
"notification_requests.explainer_for_limited_remote_account": "Kontu horren jakinarazpenak iragazi egin dira kontua edo bere zerbitzaria moderatzaile batek mugatu duelako.",
"notification_requests.maximize": "Maximizatu",
"notification_requests.minimize_banner": "Minimizatu iragazitako jakinarazpenen bannerra",
"notification_requests.notifications_from": "{name} erabiltzailearen jakinarazpenak",
"notification_requests.title": "Iragazitako jakinarazpenak",
"notification_requests.view": "Ikusi jakinarazpenak",
@ -719,8 +762,10 @@
"server_banner.about_active_users": "Azken 30 egunetan zerbitzari hau erabili duen jendea (hilabeteko erabiltzaile aktiboak)",
"server_banner.active_users": "erabiltzaile aktibo",
"server_banner.administered_by": "Administratzailea(k):",
"server_banner.is_one_of_many": "{domain} fedibertsoan parte hartzeko erabil dezakezun Mastodonen zerbitzari independenteetako bat da.",
"server_banner.server_stats": "Zerbitzariaren estatistikak:",
"sign_in_banner.create_account": "Sortu kontua",
"sign_in_banner.follow_anyone": "Jarraitu edonori fedibertsoan eta ikusi dena ordena kronologikoan. Algoritmorik gabe, iragarki edo titulu gezurtirik gabe.",
"sign_in_banner.mastodon_is": "Mastodon gertatzen ari denari buruz egunean egoteko modurik onena da.",
"sign_in_banner.sign_in": "Hasi saioa",
"sign_in_banner.sso_redirect": "Hasi saioa edo izena eman",

View file

@ -302,6 +302,7 @@
"filter_modal.select_filter.title": "Filtrer cette publication",
"filter_modal.title.status": "Filtrer une publication",
"filter_warning.matches_filter": "Correspond au filtre « {title} »",
"filtered_notifications_banner.pending_requests": "De la part {count, plural, =0 {daucune personne} one {d'une personne} other {de # personnes}} que vous pourriez connaître",
"filtered_notifications_banner.title": "Notifications filtrées",
"firehose.all": "Tout",
"firehose.local": "Ce serveur",
@ -527,7 +528,15 @@
"notification.status": "{name} vient de publier",
"notification.update": "{name} a modifié une publication",
"notification_requests.accept": "Accepter",
"notification_requests.accept_multiple": "{count, plural, one {Accepter # requête …} other {Accepter # requêtes …}}",
"notification_requests.confirm_accept_multiple.button": "{count, plural, one {Accepter la requête} other {Accepter les requêtes}}",
"notification_requests.confirm_accept_multiple.message": "Vous êtes sur le point d'accepter {count, plural, one {une requête de notification} other {# requêtes de notification}}. Êtes-vous sûr de vouloir continuer ?",
"notification_requests.confirm_accept_multiple.title": "Accepter les requêtes de notification ?",
"notification_requests.confirm_dismiss_multiple.button": "{count, plural, one {Ignorer la requête} other {Ignorer les requêtes}}",
"notification_requests.confirm_dismiss_multiple.message": "Vous êtes sur le point de rejeter {count, plural, one {une requête de notification} other {# requêtes de notification}}. Vous ne serez plus en mesure d'{count, plural, one {y} other {y}} accéder facilement, ultérieurement. Êtes-vous sûr de vouloir continuer ?",
"notification_requests.confirm_dismiss_multiple.title": "Rejeter les requêtes de notification ?",
"notification_requests.dismiss": "Rejeter",
"notification_requests.dismiss_multiple": "{count, plural, one {Rejeter # requête …} other {Rejeter # requêtes …}}",
"notification_requests.edit_selection": "Modifier",
"notification_requests.exit_selection": "Fait",
"notification_requests.explainer_for_limited_account": "Les notifications en provenance de ce compte ont été filtrées car le compte a été limité par un modérateur.",
@ -589,7 +598,7 @@
"notifications.policy.filter_not_following_title": "Personnes que vous ne suivez pas",
"notifications.policy.filter_private_mentions_hint": "Filtrées sauf si c'est en réponse à l'une de vos mentions ou si vous suivez l'expéditeur·ice",
"notifications.policy.filter_private_mentions_title": "Mentions privées non sollicitées",
"notifications.policy.title": "Gérer les notifications en provenance de …",
"notifications.policy.title": "Gestion des notifications des …",
"notifications_permission_banner.enable": "Activer les notifications de bureau",
"notifications_permission_banner.how_to_control": "Pour recevoir des notifications lorsque Mastodon nest pas ouvert, activez les notifications de bureau. Vous pouvez contrôler précisément quels types dinteractions génèrent des notifications de bureau via le bouton {icon} ci-dessus une fois quelles sont activées.",
"notifications_permission_banner.title": "Ne rien rater",

View file

@ -302,6 +302,7 @@
"filter_modal.select_filter.title": "Filtrer ce message",
"filter_modal.title.status": "Filtrer un message",
"filter_warning.matches_filter": "Correspond au filtre « {title} »",
"filtered_notifications_banner.pending_requests": "De la part {count, plural, =0 {daucune personne} one {d'une personne} other {de # personnes}} que vous pourriez connaître",
"filtered_notifications_banner.title": "Notifications filtrées",
"firehose.all": "Tout",
"firehose.local": "Ce serveur",
@ -527,7 +528,15 @@
"notification.status": "{name} vient de publier",
"notification.update": "{name} a modifié un message",
"notification_requests.accept": "Accepter",
"notification_requests.accept_multiple": "{count, plural, one {Accepter # requête …} other {Accepter # requêtes …}}",
"notification_requests.confirm_accept_multiple.button": "{count, plural, one {Accepter la requête} other {Accepter les requêtes}}",
"notification_requests.confirm_accept_multiple.message": "Vous êtes sur le point d'accepter {count, plural, one {une requête de notification} other {# requêtes de notification}}. Êtes-vous sûr de vouloir continuer ?",
"notification_requests.confirm_accept_multiple.title": "Accepter les requêtes de notification ?",
"notification_requests.confirm_dismiss_multiple.button": "{count, plural, one {Ignorer la requête} other {Ignorer les requêtes}}",
"notification_requests.confirm_dismiss_multiple.message": "Vous êtes sur le point de rejeter {count, plural, one {une requête de notification} other {# requêtes de notification}}. Vous ne serez plus en mesure d'{count, plural, one {y} other {y}} accéder facilement, ultérieurement. Êtes-vous sûr de vouloir continuer ?",
"notification_requests.confirm_dismiss_multiple.title": "Rejeter les requêtes de notification ?",
"notification_requests.dismiss": "Rejeter",
"notification_requests.dismiss_multiple": "{count, plural, one {Rejeter # requête …} other {Rejeter # requêtes …}}",
"notification_requests.edit_selection": "Modifier",
"notification_requests.exit_selection": "Fait",
"notification_requests.explainer_for_limited_account": "Les notifications en provenance de ce compte ont été filtrées car le compte a été limité par un modérateur.",
@ -589,7 +598,7 @@
"notifications.policy.filter_not_following_title": "Personnes que vous ne suivez pas",
"notifications.policy.filter_private_mentions_hint": "Filtrées sauf si c'est en réponse à l'une de vos mentions ou si vous suivez l'expéditeur·ice",
"notifications.policy.filter_private_mentions_title": "Mentions privées non sollicitées",
"notifications.policy.title": "Gérer les notifications en provenance de …",
"notifications.policy.title": "Gestion des notifications des …",
"notifications_permission_banner.enable": "Activer les notifications de bureau",
"notifications_permission_banner.how_to_control": "Pour recevoir des notifications lorsque Mastodon nest pas ouvert, activez les notifications du bureau. Vous pouvez contrôler précisément quels types dinteractions génèrent des notifications de bureau via le bouton {icon} ci-dessus une fois quelles sont activées.",
"notifications_permission_banner.title": "Toujours au courant",

View file

@ -531,6 +531,7 @@
"notification.relationships_severance_event.account_suspension": "Administrator z {from} zawiesił {target}, więc nie dostaniesz wieści ani nie wejdziesz w interakcje z użytkownikami z tego serwera.",
"notification.relationships_severance_event.domain_block": "Administrator z {from} zablokował {target}, w tym {followersCount} z Twoich obserwujących i {followingCount, plural, one {# konto} other {# konta}} które obserwujesz.",
"notification.relationships_severance_event.learn_more": "Dowiedz się więcej",
"notification.relationships_severance_event.user_domain_block": "Zablokowałeś {target}, w tym {followersCount} z Twoich obserwujących i {followingCount, plural, one {# konto} other {# konta}} które obserwujesz.",
"notification.status": "{name} opublikował(a) nowy wpis",
"notification.update": "{name} edytował(a) post",
"notification_requests.accept": "Akceptuj",

View file

@ -34,6 +34,8 @@ class Notification < ApplicationRecord
'AccountWarning' => :moderation_warning,
}.freeze
GROUPABLE_NOTIFICATION_TYPES = %i(favourite reblog emoji_reaction).freeze
# Please update app/javascript/api_types/notification.ts if you change this
PROPERTIES = {
mention: {
@ -167,17 +169,40 @@ class Notification < ApplicationRecord
end
end
def paginate_groups(limit, pagination_order)
def paginate_groups(limit, pagination_order, grouped_types: nil)
raise ArgumentError unless %i(asc desc).include?(pagination_order)
query = reorder(id: pagination_order)
# Ideally `:types` would be a bind rather than part of the SQL itself, but that does not
# seem to be possible to do with Rails, considering that the expression would occur in
# multiple places, including in a `select`
group_key_sql = begin
if grouped_types.present?
# Normalize `grouped_types` so the number of different SQL query shapes remains small, and
# the queries can be analyzed in monitoring/telemetry tools
grouped_types = (grouped_types.map(&:to_sym) & GROUPABLE_NOTIFICATION_TYPES).sort
sanitize_sql_array([<<~SQL.squish, { types: grouped_types }])
COALESCE(
CASE
WHEN notifications.type IN (:types) THEN notifications.group_key
ELSE NULL
END,
'ungrouped-' || notifications.id
)
SQL
else
"COALESCE(notifications.group_key, 'ungrouped-' || notifications.id)"
end
end
unscoped
.with_recursive(
grouped_notifications: [
# Base case: fetching one notification and annotating it with visited groups
query
.select('notifications.*', "ARRAY[COALESCE(notifications.group_key, 'ungrouped-' || notifications.id)] AS groups")
.select('notifications.*', "ARRAY[#{group_key_sql}] AS groups")
.limit(1),
# Recursive case, always yielding at most one annotated notification
unscoped
@ -192,12 +217,12 @@ class Notification < ApplicationRecord
# Recursive query, using `LATERAL` so we can refer to `wt`
query
.where(pagination_order == :desc ? 'notifications.id < wt.id' : 'notifications.id > wt.id')
.where.not("COALESCE(notifications.group_key, 'ungrouped-' || notifications.id) = ANY(wt.groups)")
.where.not("#{group_key_sql} = ANY(wt.groups)")
.limit(1)
.arel.lateral('notifications'),
]
)
.select('notifications.*', "array_append(wt.groups, COALESCE(notifications.group_key, 'ungrouped-' || notifications.id))"),
.select('notifications.*', "array_append(wt.groups, #{group_key_sql}) AS groups"),
]
)
.from('grouped_notifications AS notifications')
@ -207,28 +232,28 @@ class Notification < ApplicationRecord
# This returns notifications from the request page, but with at most one notification per group.
# Notifications that have no `group_key` each count as a separate group.
def paginate_groups_by_max_id(limit, max_id: nil, since_id: nil)
def paginate_groups_by_max_id(limit, max_id: nil, since_id: nil, grouped_types: nil)
query = reorder(id: :desc)
query = query.where(id: ...(max_id.to_i)) if max_id.present?
query = query.where(id: (since_id.to_i + 1)...) if since_id.present?
query.paginate_groups(limit, :desc)
query.paginate_groups(limit, :desc, grouped_types: grouped_types)
end
# Differs from :paginate_groups_by_max_id in that it gives the results immediately following min_id,
# whereas since_id gives the items with largest id, but with since_id as a cutoff.
# Results will be in ascending order by id.
def paginate_groups_by_min_id(limit, max_id: nil, min_id: nil)
def paginate_groups_by_min_id(limit, max_id: nil, min_id: nil, grouped_types: nil)
query = reorder(id: :asc)
query = query.where(id: (min_id.to_i + 1)...) if min_id.present?
query = query.where(id: ...(max_id.to_i)) if max_id.present?
query.paginate_groups(limit, :asc)
query.paginate_groups(limit, :asc, grouped_types: grouped_types)
end
def to_a_grouped_paginated_by_id(limit, options = {})
if options[:min_id].present?
paginate_groups_by_min_id(limit, min_id: options[:min_id], max_id: options[:max_id]).reverse
paginate_groups_by_min_id(limit, min_id: options[:min_id], max_id: options[:max_id], grouped_types: options[:grouped_types]).reverse
else
paginate_groups_by_max_id(limit, max_id: options[:max_id], since_id: options[:since_id]).to_a
paginate_groups_by_max_id(limit, max_id: options[:max_id], since_id: options[:since_id], grouped_types: options[:grouped_types]).to_a
end
end

View file

@ -11,8 +11,11 @@ class NotificationGroup < ActiveModelSerializers::Model
attributes :emoji_reaction, :sample_accounts
end
def self.from_notification(notification, max_id: nil)
if notification.group_key.present?
def self.from_notification(notification, max_id: nil, grouped_types: nil)
grouped_types = grouped_types.presence&.map(&:to_sym) || Notification::GROUPABLE_NOTIFICATION_TYPES
groupable = notification.group_key.present? && grouped_types.include?(notification.type)
if groupable
# TODO: caching, and, if caching, preloading
scope = notification.account.notifications.where(group_key: notification.group_key)
scope = scope.where(id: ..max_id) if max_id.present?
@ -36,7 +39,7 @@ class NotificationGroup < ActiveModelSerializers::Model
NotificationGroup.new(
notification: notification,
group_key: notification.group_key || "ungrouped-#{notification.id}",
group_key: groupable ? notification.group_key : "ungrouped-#{notification.id}",
sample_accounts: sample_accounts,
emoji_reaction_groups: emoji_reaction_groups,
list: list,

View file

@ -81,7 +81,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
},
media_attachments: {
supported_mime_types: MediaAttachment::IMAGE_MIME_TYPES + MediaAttachment::VIDEO_MIME_TYPES + MediaAttachment::AUDIO_MIME_TYPES,
supported_mime_types: MediaAttachment.supported_mime_types,
image_size_limit: MediaAttachment::IMAGE_LIMIT,
image_matrix_limit: Attachmentable::MAX_MATRIX_LIMIT,
video_size_limit: MediaAttachment::VIDEO_LIMIT,

View file

@ -73,7 +73,7 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
},
media_attachments: {
supported_mime_types: MediaAttachment::IMAGE_MIME_TYPES + MediaAttachment::VIDEO_MIME_TYPES + MediaAttachment::AUDIO_MIME_TYPES,
supported_mime_types: MediaAttachment.supported_mime_types,
image_size_limit: MediaAttachment::IMAGE_LIMIT,
image_matrix_limit: Attachmentable::MAX_MATRIX_LIMIT,
video_size_limit: MediaAttachment::VIDEO_LIMIT,

View file

@ -240,7 +240,7 @@ class NotifyService < BaseService
private
def notification_group_key
return nil if @notification.filtered || %i(favourite emoji_reaction reblog).exclude?(@notification.type)
return nil if @notification.filtered || Notification::GROUPABLE_NOTIFICATION_TYPES.exclude?(@notification.type)
type_prefix = "#{@notification.type}-#{@notification.target_status.id}"
redis_key = "notif-group/#{@recipient.id}/#{type_prefix}"

View file

@ -52,7 +52,7 @@
- if can?(:reset_password, account.user)
%tr
%td
= table_link_to 'key', t('admin.accounts.reset_password'), admin_account_reset_path(account.id), method: :create, data: { confirm: t('admin.accounts.are_you_sure') }
= table_link_to 'key', t('admin.accounts.reset_password'), admin_account_reset_path(account.id), method: :post, data: { confirm: t('admin.accounts.are_you_sure') }
%tr
%th= t('simple_form.labels.defaults.locale')
%td= standard_locale_name(account.user_locale)