59 lines
1.7 KiB
Ruby
59 lines
1.7 KiB
Ruby
# Sending mails related to events life cycle
|
|
class EventMailer < ApplicationMailer
|
|
helper :events
|
|
|
|
def create(event)
|
|
@event = event
|
|
|
|
mail 'Message-ID' =>
|
|
"<event-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
|
|
to: event.submitter,
|
|
subject: subject(event),
|
|
'Content-Language': locale
|
|
end
|
|
|
|
# Send email to submitter too. Before, only moderators were receiving emails
|
|
# when an event was updated
|
|
def update(event)
|
|
@event = event
|
|
@current_user = User.find_by id: event.paper_trail.originator
|
|
|
|
mail 'In-Reply-To' =>
|
|
"<event-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
|
|
to: event.submitter,
|
|
subject: subject(event),
|
|
'Content-Language': locale
|
|
end
|
|
|
|
def accept(event)
|
|
@event = event
|
|
@current_user = User.find_by id: event.paper_trail.originator
|
|
|
|
mail 'In-Reply-To' =>
|
|
"<event-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
|
|
to: event.submitter,
|
|
subject: "#{t 'mail_prefix'}#{t 'event_mailer.accept.subject',
|
|
subject: event.title}",
|
|
'Content-Language': locale
|
|
end
|
|
|
|
def destroy(event)
|
|
@event = event
|
|
@current_user = User.find_by id: event.paper_trail.originator
|
|
|
|
mail 'In-Reply-To' =>
|
|
"<event-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
|
|
to: event.submitter,
|
|
subject: "#{t 'mail_prefix'}#{t 'event_mailer.destroy.subject',
|
|
subject: event.title}",
|
|
'Content-Language': locale
|
|
end
|
|
|
|
private
|
|
|
|
def subject(event)
|
|
t('mail_prefix') +
|
|
t("#{mailer_name}.#{action_name}.subject", subject: event.title)
|
|
end
|
|
end
|