fix(inboxes): stop disabled continuity mail sends
This commit is contained in:
@@ -4,6 +4,7 @@ class ConversationReplyEmailJob < ApplicationJob
|
||||
def perform(conversation_id, last_queued_id)
|
||||
conversation = Conversation.find(conversation_id)
|
||||
return unless conversation.account.active?
|
||||
return unless conversation.inbox.active?
|
||||
|
||||
if conversation.messages.incoming&.last&.content_type == 'incoming_email'
|
||||
ConversationReplyMailer.with(account: conversation.account).reply_without_summary(conversation, last_queued_id).deliver_later
|
||||
|
||||
@@ -30,4 +30,12 @@ RSpec.describe ConversationReplyEmailJob, type: :job do
|
||||
described_class.perform_now(conversation.id, 123)
|
||||
expect(mailer).to have_received(:reply_without_summary)
|
||||
end
|
||||
|
||||
it 'does not send an email when the inbox is disabled before the job runs' do
|
||||
conversation.inbox.update!(active: false)
|
||||
|
||||
described_class.perform_now(conversation.id, 123)
|
||||
|
||||
expect(ConversationReplyMailer).not_to have_received(:with)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user