add exception notifier for failed jobs

This commit is contained in:
Connor Turland 2017-09-13 10:11:04 -04:00
parent 5af2b8f216
commit a56991aede
2 changed files with 18 additions and 3 deletions

View file

@ -8,7 +8,9 @@ class FollowService
return if (reason == 'created' || reason == 'contributed') && !should_auto_follow(entity, user, reason)
follow = Follow.where(followed: entity, user: user).first_or_create
follow.update(muted: false)
unless follow.update(muted: false)
raise follow.errors.full_messages.join("\n")
end
if FollowReason::REASONS.include?(reason) && !follow.follow_reason.read_attribute(reason)
follow.follow_reason.update_attribute(reason, true)
end
@ -16,7 +18,11 @@ class FollowService
def unfollow(entity, user)
follow = Follow.where(followed: entity, user: user).first
follow.update(muted: true)
if follow
unless follow.update(muted: true)
raise follow.errors.full_messages.join("\n")
end
end
end
def remove_reason(entity, user, reason)

View file

@ -0,0 +1,9 @@
Delayed::Worker.class_eval do
def handle_failed_job_with_notification(job, error)
handle_failed_job_without_notification(job, error)
ExceptionNotifier.notify_exception(error)
end
alias_method_chain :handle_failed_job, :notification
end