Fallback name branch (#6591)

This commit is contained in:
Tejaswini Chile
2023-03-03 12:26:59 +05:30
committed by GitHub
parent 60fee519bd
commit ec04ddc725
2 changed files with 25 additions and 1 deletions

View File

@@ -45,13 +45,18 @@ class Microsoft::CallbacksController < ApplicationController
channel_email.inbox
end
# Fallback name, for when name field is missing from users_data
def fallback_name
users_data['email'].split('@').first.parameterize.titleize
end
def create_microsoft_channel_with_inbox
ActiveRecord::Base.transaction do
channel_email = Channel::Email.create!(email: users_data['email'], account: account)
account.inboxes.create!(
account: account,
channel: channel_email,
name: users_data['name']
name: users_data['name'] || fallback_name
)
channel_email
end