feat: add Google Email fetch and OAuth token refresh service (#9603)
This PR adds the following changes 1. Add `Imap::GoogleFetchEmailService` and `Google::RefreshOauthTokenService`. The `Google::RefreshOauthTokenService` uses `OmniAuth::Strategies::GoogleOauth2` which is already added as a packge 2. Update `Inboxes::FetchImapEmailsJob` to handle Google inboxes 3. Add SMTP settings for Google in `ConversationReplyMailerHelper` to allow sending emails ## Preview #### Incoming emails  #### Outgoing email  --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
@@ -283,6 +283,22 @@ RSpec.describe ConversationReplyMailer do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when smtp enabled for google email channel' do
|
||||
let(:ms_smtp_email_channel) do
|
||||
create(:channel_email, imap_login: 'smtp@gmail.com',
|
||||
imap_enabled: true, account: account, provider: 'google', provider_config: { access_token: 'access_token' })
|
||||
end
|
||||
let(:conversation) { create(:conversation, assignee: agent, inbox: ms_smtp_email_channel.inbox, account: account).reload }
|
||||
let(:message) { create(:message, conversation: conversation, account: account, message_type: 'outgoing', content: 'Outgoing Message 2') }
|
||||
|
||||
it 'use smtp mail server' do
|
||||
mail = described_class.email_reply(message)
|
||||
expect(mail.delivery_method.settings.empty?).to be false
|
||||
expect(mail.delivery_method.settings[:address]).to eq 'smtp.gmail.com'
|
||||
expect(mail.delivery_method.settings[:port]).to eq 587
|
||||
end
|
||||
end
|
||||
|
||||
context 'when smtp disabled for email channel', :test do
|
||||
let(:conversation) { create(:conversation, assignee: agent, inbox: email_channel.inbox, account: account).reload }
|
||||
let(:message) { create(:message, conversation: conversation, account: account, message_type: 'outgoing', content: 'Outgoing Message 2') }
|
||||
|
||||
Reference in New Issue
Block a user