class NotifyEveryoneOfModerationDecisionJob < ApplicationJob - NotifyEveryoneOfModerationDecisionJob has no descriptive comment
rescue_from StandardError do |exception|
Appsignal.send_exception exception
end
def perform(petition)
creator = petition.creator -
sponsors = petition.sponsors.validated -
if petition.published? -
notify_everyone_of_publication(creator, sponsors)
elsif petition.rejected? || petition.hidden? -
notify_everyone_of_rejection(creator, sponsors)
end
end
private
def notify_everyone_of_publication(creator, sponsors) - NotifyEveryoneOfModerationDecisionJob#notify_everyone_of_publication doesn't depend on instance state (maybe move it to another class?)
NotifyCreatorThatPetitionIsPublishedEmailJob.perform_later(creator)
sponsors.each do |sponsor|
NotifySponsorThatPetitionIsPublishedEmailJob.perform_later(sponsor)
end
end
def notify_everyone_of_rejection(creator, sponsors) - NotifyEveryoneOfModerationDecisionJob#notify_everyone_of_rejection doesn't depend on instance state (maybe move it to another class?)
NotifyCreatorThatPetitionWasRejectedEmailJob.perform_later(creator)
sponsors.each do |sponsor|
NotifySponsorThatPetitionWasRejectedEmailJob.perform_later(sponsor)
end
end
end