Crowdin / Upload translations / upload-translations (push) Skipped
Historical data migration test / test (14-alpine) (push) Canceled after 0s
Historical data migration test / test (15-alpine) (push) Canceled after 0s
Historical data migration test / test (16-alpine) (push) Canceled after 0s
Historical data migration test / test (17-alpine) (push) Canceled after 0s
Bundler Audit / security (push) Canceled after 0s
Haml Linting / lint (push) Canceled after 0s
JavaScript Linting / lint (push) Canceled after 0s
Ruby Linting / lint (push) Canceled after 0s
JavaScript Testing / test (push) Canceled after 0s
Ruby Testing / build (production) (push) Canceled after 0s
Ruby Testing / test (.ruby-version) (push) Canceled after 0s
Ruby Testing / test (3.3) (push) Canceled after 0s
Ruby Testing / test (3.4) (push) Canceled after 0s
Ruby Testing / End to End testing (.ruby-version) (push) Canceled after 0s
Ruby Testing / End to End testing (3.3) (push) Canceled after 0s
Ruby Testing / End to End testing (3.4) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Canceled after 0s
Check i18n / check-i18n (push) Canceled after 0s
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (javascript) (push) Canceled after 0s
CodeQL / Analyze (ruby) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (3.4, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Canceled after 0s
Check formatting / lint (push) Canceled after 0s
CSS Linting / lint (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.19.2) (push) Canceled after 0s
Chromatic / Check for relevant changes (push) Canceled after 0s
Chromatic / Run Chromatic (push) Canceled after 0s
Snapshot of upstream tag v4.7.3 (commit 8ff11c2bb7b9f0714e947b10fa3629c6542c7121) from https://github.com/mastodon/mastodon, unmodified.
73 lines
2.2 KiB
Ruby
73 lines
2.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class REST::NotificationGroupSerializer < ActiveModel::Serializer
|
|
include RoutingHelper
|
|
include ActionView::Helpers::UrlHelper
|
|
include NotificationFallbackConcern
|
|
|
|
# Please update app/javascript/mastodon/api_types/notifications.ts when making changes to the attributes
|
|
attributes :group_key, :notifications_count, :type, :most_recent_notification_id
|
|
|
|
attribute :page_min_id, if: :paginated?
|
|
attribute :page_max_id, if: :paginated?
|
|
attribute :latest_page_notification_at, if: :paginated?
|
|
|
|
attribute :fallback, if: :needs_fallback?
|
|
|
|
attribute :sample_account_ids
|
|
attribute :status_id, if: :status_type?
|
|
belongs_to :report, if: :report_type?, serializer: REST::ReportSerializer
|
|
belongs_to :account_relationship_severance_event, key: :event, if: :relationship_severance_event?, serializer: REST::AccountRelationshipSeveranceEventSerializer
|
|
belongs_to :account_warning, key: :moderation_warning, if: :moderation_warning_event?, serializer: REST::AccountWarningSerializer
|
|
belongs_to :generated_annual_report, key: :annual_report, if: :annual_report_event?, serializer: REST::AnnualReportEventSerializer
|
|
belongs_to :target_collection, key: :collection, if: :collection_type?, serializer: REST::CollectionSerializer
|
|
|
|
def sample_account_ids
|
|
object.sample_accounts.pluck(:id).map(&:to_s)
|
|
end
|
|
|
|
def status_id
|
|
object.target_status&.id&.to_s
|
|
end
|
|
|
|
def status_type?
|
|
[:favourite, :reblog, :status, :mention, :poll, :update, :quote, :quoted_update].include?(object.type)
|
|
end
|
|
|
|
def collection_type?
|
|
[:added_to_collection, :collection_update].include?(object.type)
|
|
end
|
|
|
|
def report_type?
|
|
object.type == :'admin.report'
|
|
end
|
|
|
|
def relationship_severance_event?
|
|
object.type == :severed_relationships
|
|
end
|
|
|
|
def moderation_warning_event?
|
|
object.type == :moderation_warning
|
|
end
|
|
|
|
def annual_report_event?
|
|
object.type == :annual_report
|
|
end
|
|
|
|
def page_min_id
|
|
object.pagination_data[:min_id].to_s
|
|
end
|
|
|
|
def page_max_id
|
|
object.most_recent_notification_id.to_s
|
|
end
|
|
|
|
def latest_page_notification_at
|
|
object.pagination_data[:latest_notification_at]
|
|
end
|
|
|
|
def paginated?
|
|
object.pagination_data.present?
|
|
end
|
|
end
|