diff --git a/app/controllers/microsoft/callbacks_controller.rb b/app/controllers/microsoft/callbacks_controller.rb index 215103bd4..aa1c22d91 100644 --- a/app/controllers/microsoft/callbacks_controller.rb +++ b/app/controllers/microsoft/callbacks_controller.rb @@ -7,9 +7,14 @@ class Microsoft::CallbacksController < ApplicationController redirect_uri: "#{base_url}/microsoft/callback" ) - inbox = find_or_create_inbox + inbox, already_exists = find_or_create_inbox ::Redis::Alfred.delete(users_data['email'].downcase) - redirect_to app_microsoft_inbox_agents_url(account_id: account.id, inbox_id: inbox.id) + + if already_exists + redirect_to app_microsoft_inbox_settings_url(account_id: account.id, inbox_id: inbox.id) + else + redirect_to app_microsoft_inbox_agents_url(account_id: account.id, inbox_id: inbox.id) + end rescue StandardError => e ChatwootExceptionTracker.new(e).capture_exception redirect_to '/' @@ -40,9 +45,17 @@ class Microsoft::CallbacksController < ApplicationController def find_or_create_inbox channel_email = Channel::Email.find_by(email: users_data['email'], account: account) + # we need this value to know where to redirect on sucessful processing of the callback + channel_exists = channel_email.present? + channel_email ||= create_microsoft_channel_with_inbox update_microsoft_channel(channel_email) - channel_email.inbox + + # reauthorize channel, this code path only triggers when microsoft auth is successful + # reauthorized will also update cache keys for the associated inbox + channel_email.reauthorized! + + [channel_email.inbox, channel_exists] end # Fallback name, for when name field is missing from users_data diff --git a/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json b/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json index f887ecb87..95821069c 100644 --- a/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json +++ b/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json @@ -2,7 +2,8 @@ "INBOX_MGMT": { "HEADER": "Inboxes", "SIDEBAR_TXT": "
Inbox
When you connect a website or a facebook Page to Chatwoot, it is called an Inbox. You can have unlimited inboxes in your Chatwoot account.
Click on Add Inbox to connect a website or a Facebook Page.
In the Dashboard, you can see all the conversations from all your inboxes in a single place and respond to them under the `Conversations` tab.
You can also see conversations specific to an inbox by clicking on the inbox name on the left pane of the dashboard.
", - "RECONNECTION_REQUIRED": "Your inbox is disconnected, you will not receive any new messages. Click here to reconnect.", + "RECONNECTION_REQUIRED": "Your inbox is disconnected. You won't receive new messages until you reauthorize it.", + "CLICK_TO_RECONNECT": "Click here to reconnect.", "LIST": { "404": "There are no inboxes attached to this account." }, diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue index eb9108232..be4d94cb5 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue @@ -21,10 +21,7 @@ -