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>
52 lines
1.4 KiB
Ruby
52 lines
1.4 KiB
Ruby
class Email::FromBuilder < Email::BaseBuilder
|
|
pattr_initialize [:inbox!, :message!]
|
|
|
|
def build
|
|
return sender_name(account_support_email) unless inbox.email?
|
|
|
|
from_email = case email_channel_type
|
|
when :standard_imap_smtp,
|
|
:google_oauth,
|
|
:microsoft_oauth,
|
|
:forwarding_own_smtp
|
|
channel.email
|
|
when :imap_chatwoot_smtp,
|
|
:forwarding_chatwoot_smtp
|
|
channel.verified_for_sending ? channel.email : account_support_email
|
|
else
|
|
account_support_email
|
|
end
|
|
|
|
sender_name(from_email)
|
|
end
|
|
|
|
private
|
|
|
|
def email_channel_type
|
|
return :google_oauth if channel.google?
|
|
return :microsoft_oauth if channel.microsoft?
|
|
return :standard_imap_smtp if imap_and_smtp_enabled?
|
|
return :imap_chatwoot_smtp if imap_enabled_without_smtp?
|
|
return :forwarding_own_smtp if forwarding_with_own_smtp?
|
|
return :forwarding_chatwoot_smtp if forwarding_without_smtp?
|
|
|
|
:unknown
|
|
end
|
|
|
|
def imap_and_smtp_enabled?
|
|
channel.imap_enabled && channel.smtp_enabled
|
|
end
|
|
|
|
def imap_enabled_without_smtp?
|
|
channel.imap_enabled && !channel.smtp_enabled
|
|
end
|
|
|
|
def forwarding_with_own_smtp?
|
|
!channel.imap_enabled && channel.smtp_enabled
|
|
end
|
|
|
|
def forwarding_without_smtp?
|
|
!channel.imap_enabled && !channel.smtp_enabled
|
|
end
|
|
end
|