@ -36,17 +36,58 @@ class NotifyService < BaseService
false
false
end
end
def following_sender?
return @following_sender if defined? ( @following_sender )
@following_sender = @recipient . following? ( @notification . from_account ) || @recipient . requested? ( @notification . from_account )
end
def optional_non_follower?
@recipient . user . settings . interactions [ 'must_be_follower' ] && ! @notification . from_account . following? ( @recipient )
end
def optional_non_following?
@recipient . user . settings . interactions [ 'must_be_following' ] && ! following_sender?
end
def direct_message?
@notification . type == :mention && @notification . target_status . direct_visibility?
end
def response_to_recipient?
@notification . target_status . in_reply_to_account_id == @recipient . id
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
def from_self?
@recipient . id == @notification . from_account . id
end
def domain_blocking?
@recipient . domain_blocking? ( @notification . from_account . domain ) && ! following_sender?
end
def blocked?
def blocked?
blocked = @recipient . suspended? # Skip if the recipient account is suspended anyway
blocked || = @recipient . id == @notification . from_account . id # Skip for interactions with self
blocked || = @recipient . domain_blocking? ( @notification . from_account . domain ) && ! @recipient . following? ( @notification . from_account ) # Skip for domain blocked accounts
blocked || = @recipient . blocking? ( @notification . from_account ) # Skip for blocked accounts
blocked || = @recipient . muting? ( @notification . from_account ) # Skip for muted accounts
blocked || = ( @notification . from_account . silenced? && ! @recipient . following? ( @notification . from_account ) ) # Hellban
blocked || = ( @recipient . user . settings . interactions [ 'must_be_follower' ] && ! @notification . from_account . following? ( @recipient ) ) # Options
blocked || = ( @recipient . user . settings . interactions [ 'must_be_following' ] && ! @recipient . following? ( @notification . from_account ) ) # Options
blocked = @recipient . suspended? # Skip if the recipient account is suspended anyway
blocked || = from_self? # Skip for interactions with self
blocked || = domain_blocking? # Skip for domain blocked accounts
blocked || = @recipient . blocking? ( @notification . from_account ) # Skip for blocked accounts
blocked || = @recipient . muting? ( @notification . from_account ) # Skip for muted accounts
blocked || = hellbanned? # Hellban
blocked || = optional_non_follower? # Options
blocked || = optional_non_following? # Options
blocked || = optional_non_following_and_direct? # Options
blocked || = conversation_muted?
blocked || = conversation_muted?
blocked || = send ( " blocked_ #{ @notification . type } ? " ) # Type-dependent filters
blocked || = send ( " blocked_ #{ @notification . type } ? " ) # Type-dependent filters
blocked
blocked
end
end