Class: NotificationEmailer

Inherits:
Object
  • Object
show all
Defined in:
app/services/notification_emailer.rb

Defined Under Namespace

Classes: EmailUser

Class Method Summary collapse

Class Method Details

.disableObject



134
135
136
# File 'app/services/notification_emailer.rb', line 134

def self.disable
  @disabled = true
end

.enableObject



138
139
140
# File 'app/services/notification_emailer.rb', line 138

def self.enable
  @disabled = false
end

.process_notification(notification, no_delay: false) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'app/services/notification_emailer.rb', line 142

def self.process_notification(notification, no_delay: false)
  return if @disabled

  email_user = EmailUser.new(notification, no_delay: no_delay)
  email_method = Notification.types[notification.notification_type]

  if DiscoursePluginRegistry.email_notification_filters.any? { |filter|
       !filter.call(notification)
     }
    return
  end

  email_user.public_send(email_method) if email_user.respond_to? email_method
end