Catches error while sending notifications

pull/6827/head
Jonas Heinrich 10 years ago committed by Jens Ulferts
parent 95b05e9924
commit 8f7907b6f7
  1. 12
      app/controllers/meeting_contents_controller.rb
  2. 1
      config/locales/de.yml
  3. 1
      config/locales/en.yml
  4. 2
      spec/controllers/meeting_contents_controller_spec.rb

@ -85,8 +85,18 @@ class MeetingContentsController < ApplicationController
unless @content.new_record?
recipients = @content.meeting.participants.collect(&:mail).reject { |r| r == @content.meeting.author.mail }
recipients << @content.meeting.author.mail unless @content.meeting.author.preference[:no_self_notified]
recipients_with_errors = []
recipients.each do |recipient|
MeetingMailer.content_for_review(@content, @content_type, recipient).deliver
begin
MeetingMailer.content_for_review(@content, @content_type, recipient).deliver
rescue
recipients_with_errors << recipient
end
end
if recipients_with_errors == []
flash[:notice] = l(:notice_successful_notification)
else
flash[:notice] = l(:notice_notification_with_errors) + recipients_with_errors.join(", ")
end
end
redirect_back_or_default controller: '/meetings', action: 'show', id: @meeting

@ -64,6 +64,7 @@ de:
label_version: "Version"
notice_successful_notification: "Benachrichtigung erfolgreich gesendet"
notice_notification_with_errors: "Benachrichtigung gesendet. Folgende Empfänger konnten nicht benachrichtigt werden: "
notice_timezone_missing: Keine Zeitzone eingestellt und daher %{zone} angenommen. Um Ihre Zeitzone einzustellen, klicken Sie bitte hier.
permission_create_meetings: "Besprechungen erstellen"

@ -64,6 +64,7 @@ en:
label_version: "Version"
notice_successful_notification: "Notification sent successfully"
notice_notification_with_errors: "Notification sent. The following recipients could not be notified: "
notice_timezone_missing: No time zone is set and %{zone} is assumed. To choose your time zone, please click here.
permission_create_meetings: "Create meetings"

@ -86,7 +86,7 @@ describe MeetingContentsController do
it 'produces a flash message containing the mail addresses raising the error' do
put 'notify', meeting_id: meeting.id
meeting.participants.each do |participant|
expect(flash[:error]).to include(participant.name)
expect(flash[:notice]).to include(participant.mail)
end
end
end

Loading…
Cancel
Save