mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-30 02:32:29 +00:00
We first added conversation continuity for the live chat widget, and then carried the same logic over to email channels. The problem was that this added a reply+conversationUUID@domain.com as the reply-to for emails, which was unnecessary. For email channels, the reply-to can just be the channel’s own email address. That extra layer made things more complex than it needed to be. In this PR, I’ve cleaned up the config so it’s simpler. The table below shows how it’ll work going forward. --- | Type | From Email | Reply To Email | | -- | -- | -- | | Standard IMAP, SMTP email channel | channel.email | channel.email | | Google OAuth Email channel | channel.email | channel.email | | Microsoft OAuth Email channel | channel.email | channel.email | | Email forwarded to Chatwoot, brought their own SMTP | channel.email | channel.email | | Imap to fetch email, Use Chatwoot's SMTP | channel.email if verified with Chatwoot's SMTP provider. Otherwise account support email | channel.email | | Email forwarded to Chatwoot, Use Chatwoot's SMTP | channel.email if verified with Chatwoot's SMTP provider. Otherwise account support email | channel.email | | -- | -- | -- | | Website Live Chat - Conversation Continuity Inbound Emails enabled| Account Support Email | reply+{conversation-uuid}@{account_domain} | | Website Live Chat - Conversation Continuity Inbound Emails disabled| Account Support Email | Account Support Email | Fixes https://github.com/chatwoot/chatwoot/issues/10614 Fixes https://github.com/chatwoot/chatwoot/issues/10521 Fixes https://github.com/chatwoot/chatwoot/issues/10300 Fixes https://github.com/chatwoot/chatwoot/issues/10091 Fixes https://github.com/chatwoot/chatwoot/issues/4890 Fixes https://github.com/chatwoot/chatwoot/issues/10676 Fixes https://github.com/chatwoot/chatwoot/issues/10756 Fixes https://github.com/chatwoot/chatwoot/issues/11515 Fixes https://github.com/chatwoot/chatwoot/issues/9471 --------- Co-authored-by: Sojan Jose <sojan@pepalo.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
170 lines
5.8 KiB
Ruby
170 lines
5.8 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe Email::FromBuilder do
|
|
let(:account) { create(:account, support_email: 'support@example.com') }
|
|
let(:agent) { create(:user, account: account) }
|
|
let(:conversation) { create(:conversation, account: account) }
|
|
let(:current_message) { create(:message, conversation: conversation, sender: agent, message_type: :outgoing) }
|
|
|
|
describe '#build' do
|
|
context 'when inbox is not an email channel' do
|
|
let(:channel) { create(:channel_api, account: account) }
|
|
let(:inbox) { create(:inbox, channel: channel, account: account) }
|
|
|
|
it 'returns account support email with sender name formatting' do
|
|
builder = described_class.new(inbox: inbox, message: current_message)
|
|
result = builder.build
|
|
|
|
expect(result).to include('support@example.com')
|
|
end
|
|
|
|
context 'with friendly inbox' do
|
|
let(:inbox) { create(:inbox, channel: channel, account: account, sender_name_type: :friendly) }
|
|
|
|
it 'returns friendly formatted sender name with support email' do
|
|
builder = described_class.new(inbox: inbox, message: current_message)
|
|
result = builder.build
|
|
|
|
expect(result).to include(agent.available_name)
|
|
expect(result).to include('support@example.com')
|
|
end
|
|
end
|
|
|
|
context 'with professional inbox' do
|
|
let(:inbox) { create(:inbox, channel: channel, account: account, sender_name_type: :professional) }
|
|
|
|
it 'returns professional formatted sender name with support email' do
|
|
builder = described_class.new(inbox: inbox, message: current_message)
|
|
result = builder.build
|
|
|
|
expect(result).to include('support@example.com')
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'when inbox is an email channel' do
|
|
let(:channel) { create(:channel_email, email: 'care@example.com', account: account) }
|
|
let(:inbox) { create(:inbox, channel: channel, account: account) }
|
|
|
|
context 'with standard IMAP/SMTP configuration' do
|
|
before do
|
|
channel.update!(
|
|
imap_enabled: true,
|
|
smtp_enabled: true,
|
|
imap_address: 'imap.example.com',
|
|
smtp_address: 'smtp.example.com'
|
|
)
|
|
end
|
|
|
|
it 'returns channel email with sender name formatting' do
|
|
builder = described_class.new(inbox: inbox, message: current_message)
|
|
result = builder.build
|
|
|
|
expect(result).to include('care@example.com')
|
|
end
|
|
end
|
|
|
|
context 'with Google OAuth configuration' do
|
|
before do
|
|
channel.update!(
|
|
provider: 'google',
|
|
imap_enabled: true,
|
|
provider_config: { access_token: 'token', refresh_token: 'refresh' }
|
|
)
|
|
end
|
|
|
|
it 'returns channel email with sender name formatting' do
|
|
builder = described_class.new(inbox: inbox, message: current_message)
|
|
result = builder.build
|
|
|
|
expect(result).to include('care@example.com')
|
|
end
|
|
end
|
|
|
|
context 'with Microsoft OAuth configuration' do
|
|
before do
|
|
channel.update!(
|
|
provider: 'microsoft',
|
|
imap_enabled: true,
|
|
provider_config: { access_token: 'token', refresh_token: 'refresh' }
|
|
)
|
|
end
|
|
|
|
it 'returns channel email with sender name formatting' do
|
|
builder = described_class.new(inbox: inbox, message: current_message)
|
|
result = builder.build
|
|
|
|
expect(result).to include('care@example.com')
|
|
end
|
|
end
|
|
|
|
context 'with forwarding and own SMTP configuration' do
|
|
before do
|
|
channel.update!(
|
|
imap_enabled: false,
|
|
smtp_enabled: true,
|
|
smtp_address: 'smtp.example.com'
|
|
)
|
|
end
|
|
|
|
it 'returns channel email with sender name formatting' do
|
|
builder = described_class.new(inbox: inbox, message: current_message)
|
|
result = builder.build
|
|
|
|
expect(result).to include('care@example.com')
|
|
end
|
|
end
|
|
|
|
context 'with IMAP enabled and Chatwoot SMTP and channel is verified_for_sending' do
|
|
before do
|
|
channel.update!(verified_for_sending: true, imap_enabled: true, smtp_enabled: false)
|
|
end
|
|
|
|
it 'returns channel email with sender name formatting' do
|
|
builder = described_class.new(inbox: inbox, message: current_message)
|
|
result = builder.build
|
|
|
|
expect(result).to include('care@example.com')
|
|
end
|
|
end
|
|
|
|
context 'with IMAP enabled and Chatwoot SMTP and channel is not verified_for_sending' do
|
|
before do
|
|
channel.update!(verified_for_sending: false, imap_enabled: true, smtp_enabled: false)
|
|
end
|
|
|
|
it 'returns account support email with sender name formatting' do
|
|
builder = described_class.new(inbox: inbox, message: current_message)
|
|
result = builder.build
|
|
|
|
expect(result).to include('support@example.com')
|
|
end
|
|
end
|
|
|
|
context 'with forwarding and Chatwoot SMTP and channel is verified_for_sending' do
|
|
before do
|
|
channel.update!(verified_for_sending: true, imap_enabled: false, smtp_enabled: false)
|
|
end
|
|
|
|
it 'returns channel email with sender name formatting' do
|
|
builder = described_class.new(inbox: inbox, message: current_message)
|
|
result = builder.build
|
|
|
|
expect(result).to include('care@example.com')
|
|
end
|
|
end
|
|
|
|
context 'with forwarding and Chatwoot SMTP and channel is not verified_for_sending' do
|
|
before { channel.update!(verified_for_sending: false, imap_enabled: false, smtp_enabled: false) }
|
|
|
|
it 'returns account support email with sender name formatting' do
|
|
builder = described_class.new(inbox: inbox, message: current_message)
|
|
result = builder.build
|
|
|
|
expect(result).to include('support@example.com')
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|