[WiP] Add notification type for relationship severance events
This commit is contained in:
parent
1d2859c6e1
commit
8622abe6aa
|
@ -37,6 +37,7 @@ class Notification < ApplicationRecord
|
|||
favourite
|
||||
poll
|
||||
update
|
||||
relationships_severed
|
||||
admin.sign_up
|
||||
admin.report
|
||||
).freeze
|
||||
|
@ -63,6 +64,7 @@ class Notification < ApplicationRecord
|
|||
belongs_to :favourite, inverse_of: :notification
|
||||
belongs_to :poll, inverse_of: false
|
||||
belongs_to :report, inverse_of: false
|
||||
belongs_to :relationship_severance_event, inverse_of: false
|
||||
end
|
||||
|
||||
validates :type, inclusion: { in: TYPES }
|
||||
|
@ -156,6 +158,11 @@ class Notification < ApplicationRecord
|
|||
self.from_account_id = activity&.status&.account_id
|
||||
when 'Account'
|
||||
self.from_account_id = activity&.id
|
||||
when 'RelationshipSeveranceEvent'
|
||||
# These do not really have an originating account, but this is mandatory
|
||||
# in the data model, and the recipient's account will by definition
|
||||
# always exist
|
||||
self.from_account_id = account_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,7 @@ class REST::NotificationSerializer < ActiveModel::Serializer
|
|||
belongs_to :from_account, key: :account, serializer: REST::AccountSerializer
|
||||
belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer
|
||||
belongs_to :report, if: :report_type?, serializer: REST::ReportSerializer
|
||||
belongs_to :relationship_severance_event, key: :event, if: :relationship_severance_event?, serializer: REST::RelationshipSeveranceEventSerializer
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
|
@ -18,4 +19,8 @@ class REST::NotificationSerializer < ActiveModel::Serializer
|
|||
def report_type?
|
||||
object.type == :'admin.report'
|
||||
end
|
||||
|
||||
def relationship_severance_event?
|
||||
object.type == :relationship_severance_event
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class REST::RelationshipSeveranceEventSerializer < ActiveModel::Serializer
|
||||
attributes :id, :type, :domain, :created_at
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
end
|
|
@ -109,7 +109,7 @@ class NotifyService < BaseService
|
|||
|
||||
def blocked?
|
||||
blocked = @recipient.suspended?
|
||||
blocked ||= from_self? && @notification.type != :poll
|
||||
blocked ||= from_self? && @notification.type != :poll && @notification.type != :relationships_severed
|
||||
|
||||
return blocked if message? && from_staff?
|
||||
|
||||
|
|
Loading…
Reference in New Issue