2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
module Jobs
|
|
|
|
# Asynchronously send an email
|
2019-10-02 00:01:53 -04:00
|
|
|
class InviteEmail < ::Jobs::Base
|
2013-02-05 14:16:51 -05:00
|
|
|
def execute(args)
|
|
|
|
raise Discourse::InvalidParameters.new(:invite_id) unless args[:invite_id].present?
|
|
|
|
|
2014-05-06 09:41:59 -04:00
|
|
|
invite = Invite.find_by(id: args[:invite_id])
|
2018-08-29 06:02:47 -04:00
|
|
|
return unless invite.present?
|
|
|
|
|
2021-03-16 11:08:54 -04:00
|
|
|
message = InviteMailer.send_invite(invite, invite_to_topic: args[:invite_to_topic])
|
2013-06-10 15:33:37 -04:00
|
|
|
Email::Sender.new(message, :invite).send
|
2013-02-05 14:16:51 -05:00
|
|
|
|
2019-07-19 01:59:12 -04:00
|
|
|
if invite.emailed_status != Invite.emailed_status_types[:not_required]
|
|
|
|
invite.update_column(:emailed_status, Invite.emailed_status_types[:sent])
|
|
|
|
end
|
|
|
|
end
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
end
|