Les mails peuvent maintenant gérés en converstation grâce aux headers message-id et in-reply-to
This commit is contained in:
parent
de9b22ddb0
commit
bb35cddaeb
@ -3,6 +3,9 @@ class EventMailer < ActionMailer::Base
|
||||
|
||||
def create(event)
|
||||
@event = event
|
||||
mail to: event.contact, subject: t('event_mailer.create.subject', subject: event.title)
|
||||
|
||||
mail 'Message-ID' => "<event-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
|
||||
to: event.contact,
|
||||
subject: t('event_mailer.create.subject', subject: event.title)
|
||||
end
|
||||
end
|
||||
|
@ -1,16 +1,12 @@
|
||||
class ModerationMailer < ActionMailer::Base
|
||||
default from: 'moderateurs@agendadulibre.org'
|
||||
TO = 'moderateurs@agendadulibre.org'
|
||||
default to: 'moderateurs@agendadulibre.org'
|
||||
|
||||
# Subject can be set in your I18n file at config/locales/en.yml
|
||||
# with the following lookup:
|
||||
#
|
||||
# en.moderation_mailer.create.subject
|
||||
#
|
||||
def create(event)
|
||||
@event = event
|
||||
|
||||
mail to: TO, subject: t('moderation_mailer.create.subject', subject: event.title)
|
||||
mail 'Message-ID' => "<mod-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
|
||||
subject: t('moderation_mailer.create.subject', subject: event.title)
|
||||
end
|
||||
|
||||
# Subject can be set in your I18n file at config/locales/en.yml
|
||||
@ -22,7 +18,8 @@ class ModerationMailer < ActionMailer::Base
|
||||
@event = event
|
||||
@current_user = current_user
|
||||
|
||||
mail to: TO, subject: t('moderation_mailer.update.subject', subject: event.title)
|
||||
mail 'In-Reply-To' => "<mod-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
|
||||
subject: t('moderation_mailer.update.subject', subject: event.title)
|
||||
end
|
||||
|
||||
# Subject can be set in your I18n file at config/locales/en.yml
|
||||
@ -34,6 +31,7 @@ class ModerationMailer < ActionMailer::Base
|
||||
@event = event
|
||||
@current_user = current_user
|
||||
|
||||
mail to: TO, subject: t('moderation_mailer.moderate.subject', subject: event.title)
|
||||
mail 'In-Reply-To' => "<mod-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
|
||||
subject: t('moderation_mailer.moderate.subject', subject: event.title)
|
||||
end
|
||||
end
|
||||
|
@ -4,6 +4,8 @@ class NoteMailer < ActionMailer::Base
|
||||
def create(note)
|
||||
@note = note
|
||||
|
||||
mail to: note.event.contact, subject: t('note_mailer.create.subject', subject: note.event.title)
|
||||
mail 'In-Reply-To' => "<event-#{note.event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
|
||||
to: note.event.contact,
|
||||
subject: t('note_mailer.create.subject', subject: note.event.title)
|
||||
end
|
||||
end
|
||||
|
@ -2,7 +2,7 @@ class Event < ActiveRecord::Base
|
||||
extend SimpleCalendar
|
||||
|
||||
belongs_to :region, foreign_key: 'region'
|
||||
has_many :notes
|
||||
has_many :notes, dependent: :destroy
|
||||
has_one :related_city, foreign_key: :name, primary_key: :city, class_name: City
|
||||
|
||||
validates_presence_of :title, :description, :city, :region, :url, :contact
|
||||
|
@ -5,12 +5,11 @@ class EventMailerTest < ActionMailer::TestCase
|
||||
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
|
||||
end
|
||||
|
||||
test "create" do
|
||||
mail = EventMailer.create(Event.last)
|
||||
test 'create' do
|
||||
mail = EventMailer.create Event.last
|
||||
assert_match(/\[Agenda du Libre\] Votre évènement: .* est en attente de modération/, mail.subject)
|
||||
assert_equal [Event.last.contact], mail.to
|
||||
assert_equal ["moderateurs@agendadulibre.org"], mail.from
|
||||
assert_equal ['moderateurs@agendadulibre.org'], mail.from
|
||||
assert_match(/Bonjour.*/, mail.body.encoded)
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user