Change user settings to be stored in a more optimal way (#23630)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
e7c3e55874
commit
a9b5598c97
36 changed files with 817 additions and 525 deletions
|
@ -3,6 +3,11 @@
|
|||
class NotifyService < BaseService
|
||||
include Redisable
|
||||
|
||||
NON_EMAIL_TYPES = %i(
|
||||
admin.report
|
||||
admin.sign_up
|
||||
).freeze
|
||||
|
||||
def call(recipient, type, activity)
|
||||
@recipient = recipient
|
||||
@activity = activity
|
||||
|
@ -36,11 +41,11 @@ class NotifyService < BaseService
|
|||
end
|
||||
|
||||
def optional_non_follower?
|
||||
@recipient.user.settings.interactions['must_be_follower'] && !@notification.from_account.following?(@recipient)
|
||||
@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?
|
||||
@recipient.user.settings['interactions.must_be_following'] && !following_sender?
|
||||
end
|
||||
|
||||
def message?
|
||||
|
@ -82,7 +87,7 @@ class NotifyService < BaseService
|
|||
|
||||
def optional_non_following_and_direct?
|
||||
direct_message? &&
|
||||
@recipient.user.settings.interactions['must_be_following_dm'] &&
|
||||
@recipient.user.settings['interactions.must_be_following_dm'] &&
|
||||
!following_sender? &&
|
||||
!response_to_recipient?
|
||||
end
|
||||
|
@ -171,6 +176,6 @@ class NotifyService < BaseService
|
|||
end
|
||||
|
||||
def send_email_for_notification_type?
|
||||
@recipient.user.settings.notification_emails[@notification.type.to_s]
|
||||
NON_EMAIL_TYPES.exclude?(@notification.type) && @recipient.user.settings["notification_emails.#{@notification.type}"]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue