refactor: move update_channel

This commit is contained in:
Shivam Mishra
2024-06-02 19:27:26 +05:30
parent d7b564ea9f
commit df373bec62
2 changed files with 25 additions and 25 deletions
@@ -5,14 +5,8 @@ class Microsoft::CallbacksController < OauthCallbackController
'microsoft'
end
def handle_response
inbox, already_exists = find_or_create_inbox
if already_exists
redirect_to app_email_inbox_settings_url(account_id: account.id, inbox_id: inbox.id)
else
redirect_to app_email_inbox_agents_url(account_id: account.id, inbox_id: inbox.id)
end
def imap_address
'outlook.office365.com'
end
def oauth_client
@@ -26,17 +20,4 @@ class Microsoft::CallbacksController < OauthCallbackController
token_url: 'https://login.microsoftonline.com/common/oauth2/v2.0/token'
})
end
def update_channel(channel_email)
channel_email.update!({
imap_login: users_data['email'], imap_address: 'outlook.office365.com',
imap_port: '993', imap_enabled: true,
provider: 'microsoft',
provider_config: {
access_token: parsed_body['access_token'],
refresh_token: parsed_body['refresh_token'],
expires_on: (Time.current.utc + 1.hour).to_s
}
})
end
end