Class: Decidim::NotificationMailer

Inherits:
ApplicationMailer show all
Defined in:
decidim-core/app/mailers/decidim/notification_mailer.rb

Overview

A custom mailer for sending notifications to users when a events are received.

Instance Method Summary collapse

Instance Method Details

#event_received(event, event_class_name, resource, user, user_role, extra) ⇒ Object

rubocop:disable Metrics/ParameterLists


9
10
11
12
13
14
15
16
17
18
# File 'decidim-core/app/mailers/decidim/notification_mailer.rb', line 9

def event_received(event, event_class_name, resource, user, user_role, extra) # rubocop:disable Metrics/ParameterLists
  with_user(user) do
    @organization = user.organization
    event_class = event_class_name.constantize
    @event_instance = event_class.new(resource: resource, event_name: event, user: user, extra: extra, user_role: user_role)
    subject = @event_instance.email_subject

    mail(to: user.email, subject: subject)
  end
end