2014-08-06 14:47:47 +02:00
|
|
|
# Sending mails related to events life cycle
|
2015-07-25 18:32:27 +02:00
|
|
|
class EventMailer < ApplicationMailer
|
2014-08-16 17:39:24 +02:00
|
|
|
helper :events
|
|
|
|
|
2014-05-25 23:59:03 +02:00
|
|
|
def create(event)
|
|
|
|
@event = event
|
2014-06-29 13:37:08 +02:00
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
mail 'Message-ID' =>
|
|
|
|
"<event-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
|
|
|
|
to: event.submitter,
|
2019-12-22 11:58:20 +01:00
|
|
|
subject: subject(event),
|
|
|
|
'Content-Language': locale
|
2014-05-25 23:59:03 +02:00
|
|
|
end
|
2014-07-01 21:55:38 +02:00
|
|
|
|
2016-10-31 22:35:14 +01:00
|
|
|
# Send email to submitter too. Before, only moderators were receiving emails
|
|
|
|
# when an event was updated
|
2016-10-28 19:14:24 +02:00
|
|
|
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,
|
2019-12-22 11:58:20 +01:00
|
|
|
subject: subject(event),
|
|
|
|
'Content-Language': locale
|
2016-10-28 19:14:24 +02:00
|
|
|
end
|
|
|
|
|
2015-10-22 21:14:36 +02:00
|
|
|
def accept(event)
|
2014-07-01 21:55:38 +02:00
|
|
|
@event = event
|
2016-07-02 16:48:47 +02:00
|
|
|
@current_user = User.find_by id: event.paper_trail.originator
|
2014-07-01 21:55:38 +02:00
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
mail 'In-Reply-To' =>
|
|
|
|
"<event-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
|
|
|
|
to: event.submitter,
|
2014-09-20 17:20:40 +02:00
|
|
|
subject: "#{t 'mail_prefix'}#{t 'event_mailer.accept.subject',
|
2019-12-22 11:58:20 +01:00
|
|
|
subject: event.title}",
|
|
|
|
'Content-Language': locale
|
2014-07-01 21:55:38 +02:00
|
|
|
end
|
2014-07-07 13:14:17 +02:00
|
|
|
|
2015-10-22 21:14:36 +02:00
|
|
|
def destroy(event)
|
2014-07-07 13:14:17 +02:00
|
|
|
@event = event
|
2016-07-02 16:48:47 +02:00
|
|
|
@current_user = User.find_by id: event.paper_trail.originator
|
2014-07-07 13:14:17 +02:00
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
mail 'In-Reply-To' =>
|
|
|
|
"<event-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
|
|
|
|
to: event.submitter,
|
2014-09-20 17:20:40 +02:00
|
|
|
subject: "#{t 'mail_prefix'}#{t 'event_mailer.destroy.subject',
|
2019-12-22 11:58:20 +01:00
|
|
|
subject: event.title}",
|
|
|
|
'Content-Language': locale
|
2014-07-07 13:14:17 +02:00
|
|
|
end
|
2016-11-07 22:30:44 +01:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def subject(event)
|
|
|
|
t('mail_prefix') +
|
|
|
|
t("#{mailer_name}.#{action_name}.subject", subject: event.title)
|
|
|
|
end
|
2014-05-25 23:59:03 +02:00
|
|
|
end
|