chore: Disable email processing for suspended accounts (#5762)
- Disable email processing for suspended accounts
This commit is contained in:
parent
352558dd11
commit
12cd15b6ad
2 changed files with 22 additions and 0 deletions
|
@ -7,6 +7,8 @@ class SupportMailbox < ApplicationMailbox
|
||||||
:decorate_mail
|
:decorate_mail
|
||||||
|
|
||||||
def process
|
def process
|
||||||
|
# to turn off spam conversation creation
|
||||||
|
return unless @account.active?
|
||||||
# prevent loop from chatwoot notification emails
|
# prevent loop from chatwoot notification emails
|
||||||
return if notification_email_from_chatwoot?
|
return if notification_email_from_chatwoot?
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,26 @@ RSpec.describe SupportMailbox, type: :mailbox do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'when an account is suspended' do
|
||||||
|
let(:account) { create(:account, status: :suspended) }
|
||||||
|
let(:agent) { create(:user, email: 'agent1@example.com', account: account) }
|
||||||
|
let!(:channel_email) { create(:channel_email, account: account) }
|
||||||
|
let(:support_mail) { create_inbound_email_from_fixture('support.eml') }
|
||||||
|
let(:described_subject) { described_class.receive support_mail }
|
||||||
|
let(:conversation) { Conversation.where(inbox_id: channel_email.inbox).last }
|
||||||
|
|
||||||
|
before do
|
||||||
|
# this email is hardcoded in the support.eml, that's why we are updating this
|
||||||
|
channel_email.email = 'care@example.com'
|
||||||
|
channel_email.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'shouldnt create a conversation in the channel' do
|
||||||
|
described_subject
|
||||||
|
expect(conversation.present?).to be(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'add mail as a new ticket in the email inbox' do
|
describe 'add mail as a new ticket in the email inbox' do
|
||||||
let(:account) { create(:account) }
|
let(:account) { create(:account) }
|
||||||
let(:agent) { create(:user, email: 'agent1@example.com', account: account) }
|
let(:agent) { create(:user, email: 'agent1@example.com', account: account) }
|
||||||
|
|
Loading…
Reference in a new issue