Remove code duplication for catching errors when sending mails
This commit is contained in:
parent
0ed3b7b7c3
commit
2264351cf5
4 changed files with 27 additions and 22 deletions
|
|
@ -7,10 +7,10 @@ namespace :foodsoft do
|
|||
for task in tasks
|
||||
rake_say "Send notifications for #{task.name} to .."
|
||||
for user in task.users
|
||||
begin
|
||||
Mailer.upcoming_tasks(user, task).deliver_now if user.settings.notify['upcoming_tasks'] == 1
|
||||
rescue
|
||||
rake_say "deliver aborted for #{user.email}.."
|
||||
if user.settings.notify['upcoming_tasks']
|
||||
Mailer.deliver_now_with_user_locale user do
|
||||
Mailer.upcoming_tasks(user, task)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -26,10 +26,8 @@ namespace :foodsoft do
|
|||
rake_say "Notify workgroup: #{workgroup.name} for task #{task.name}"
|
||||
for user in workgroup.users
|
||||
if user.receive_email?
|
||||
begin
|
||||
Mailer.not_enough_users_assigned(task, user).deliver_now
|
||||
rescue
|
||||
rake_say "deliver aborted for #{user.email}"
|
||||
Mailer.deliver_now_with_user_locale user do
|
||||
Mailer.not_enough_users_assigned(task, user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue