From 7889e983fbe7e29f3f91784cfa2117e620514ad7 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 20 Jun 2024 13:05:25 +0200 Subject: [PATCH] Add `group_key` attribute to `NotificationSerializer` (#30776) Co-authored-by: Renaud Chaput --- app/serializers/rest/notification_serializer.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/serializers/rest/notification_serializer.rb b/app/serializers/rest/notification_serializer.rb index 417245d19..966819585 100644 --- a/app/serializers/rest/notification_serializer.rb +++ b/app/serializers/rest/notification_serializer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class REST::NotificationSerializer < ActiveModel::Serializer - attributes :id, :type, :created_at + attributes :id, :type, :created_at, :group_key belongs_to :from_account, key: :account, serializer: REST::AccountSerializer belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer @@ -13,6 +13,10 @@ class REST::NotificationSerializer < ActiveModel::Serializer object.id.to_s end + def group_key + object.group_key || "ungrouped-#{object.id}" + end + def status_type? [:favourite, :reblog, :status, :mention, :poll, :update].include?(object.type) end