Commiting
This commit is contained in:
@@ -10,7 +10,6 @@ class NotifyService < BaseService
|
||||
|
||||
create_notification!
|
||||
push_notification! if @notification.browserable?
|
||||
push_to_conversation! if direct_message?
|
||||
send_email! if email_enabled?
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
return
|
||||
@@ -59,25 +58,10 @@ class NotifyService < BaseService
|
||||
@notification.type == :mention
|
||||
end
|
||||
|
||||
def direct_message?
|
||||
message? && @notification.target_status.direct_visibility?
|
||||
end
|
||||
|
||||
def response_to_recipient?
|
||||
@notification.target_status.in_reply_to_account_id == @recipient.id && @notification.target_status.thread&.direct_visibility?
|
||||
end
|
||||
|
||||
def from_staff?
|
||||
@notification.from_account.local? && @notification.from_account.user.present? && @notification.from_account.user.staff?
|
||||
end
|
||||
|
||||
def optional_non_following_and_direct?
|
||||
direct_message? &&
|
||||
@recipient.user.settings.interactions['must_be_following_dm'] &&
|
||||
!following_sender? &&
|
||||
!response_to_recipient?
|
||||
end
|
||||
|
||||
def hellbanned?
|
||||
@notification.from_account.silenced? && !following_sender?
|
||||
end
|
||||
@@ -86,36 +70,21 @@ class NotifyService < BaseService
|
||||
@recipient.id == @notification.from_account.id
|
||||
end
|
||||
|
||||
def domain_blocking?
|
||||
@recipient.domain_blocking?(@notification.from_account.domain) && !following_sender?
|
||||
end
|
||||
|
||||
def blocked?
|
||||
blocked = @recipient.suspended? # Skip if the recipient account is suspended anyway
|
||||
blocked ||= from_self? && @notification.type != :poll # Skip for interactions with self
|
||||
|
||||
return blocked if message? && from_staff?
|
||||
|
||||
blocked ||= domain_blocking? # Skip for domain blocked accounts
|
||||
blocked ||= @recipient.blocking?(@notification.from_account) # Skip for blocked accounts
|
||||
blocked ||= @recipient.muting_notifications?(@notification.from_account)
|
||||
blocked ||= hellbanned? # Hellban
|
||||
blocked ||= optional_non_follower? # Options
|
||||
blocked ||= optional_non_following? # Options
|
||||
blocked ||= optional_non_following_and_direct? # Options
|
||||
blocked ||= conversation_muted?
|
||||
blocked ||= send("blocked_#{@notification.type}?") # Type-dependent filters
|
||||
blocked
|
||||
end
|
||||
|
||||
def conversation_muted?
|
||||
if @notification.target_status
|
||||
@recipient.muting_conversation?(@notification.target_status.conversation)
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def create_notification!
|
||||
@notification.save!
|
||||
end
|
||||
@@ -127,11 +96,6 @@ class NotifyService < BaseService
|
||||
send_push_notifications!
|
||||
end
|
||||
|
||||
def push_to_conversation!
|
||||
return if @notification.activity.nil?
|
||||
AccountConversation.add_status(@recipient, @notification.target_status)
|
||||
end
|
||||
|
||||
def send_push_notifications!
|
||||
subscriptions_ids = ::Web::PushSubscription.where(user_id: @recipient.user.id)
|
||||
.select { |subscription| subscription.pushable?(@notification) }
|
||||
|
||||
Reference in New Issue
Block a user