about summary refs log tree commit diff
path: root/app/services/notify_service.rb
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2023-04-14 19:22:47 -0500
committerStarfall <us@starfall.systems>2023-04-14 19:22:47 -0500
commit4fe1689de43f4404eb9530fcfbcbfb26d6c1c13a (patch)
tree6811b845bb7f4966b10dcefa3dea404246f161c7 /app/services/notify_service.rb
parent65c1e53a32cabcdbb7bca57002bb0f6acdebe07e (diff)
parentbed63f6dae0879ac840066b031229e0d139089cd (diff)
Merge remote-tracking branch 'glitch/main' HEAD main
Diffstat (limited to 'app/services/notify_service.rb')
-rw-r--r--app/services/notify_service.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb
index c7454fc60..069f370cf 100644
--- a/app/services/notify_service.rb
+++ b/app/services/notify_service.rb
@@ -3,6 +3,12 @@
 class NotifyService < BaseService
   include Redisable
 
+  NON_EMAIL_TYPES = %i(
+    admin.report
+    admin.sign_up
+    update
+  ).freeze
+
   def call(recipient, type, activity)
     @recipient    = recipient
     @activity     = activity
@@ -31,15 +37,16 @@ class NotifyService < BaseService
 
   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)
+    @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?
@@ -81,7 +88,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
@@ -170,6 +177,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