Follow up - db3f553140
- Office365 and Google channel:
- Enhancement: Refresh Google and Office365 page every 30 seconds to display possible errors. - Refactoring: Removed unused method `ExternalCredentials::Office365.user_aliases`. - Fixes: Technical incompatibility between Google and Office365 causes Google view to break. - Fixes: Broken duplicate Email detection.
This commit is contained in:
parent
1a3650f730
commit
ab6b68942c
3 changed files with 22 additions and 52 deletions
|
@ -10,7 +10,7 @@ class App.ChannelGoogle extends App.ControllerTabs
|
|||
{
|
||||
name: 'Accounts',
|
||||
target: 'c-account',
|
||||
controller: ChannelGoogleAccountOverview,
|
||||
controller: ChannelAccountOverview,
|
||||
},
|
||||
{
|
||||
name: 'Filter',
|
||||
|
@ -32,7 +32,7 @@ class App.ChannelGoogle extends App.ControllerTabs
|
|||
|
||||
@render()
|
||||
|
||||
class ChannelGoogleAccountOverview extends App.ControllerSubContent
|
||||
class ChannelAccountOverview extends App.ControllerSubContent
|
||||
requiredPermission: 'admin.channel_google'
|
||||
events:
|
||||
'click .js-new': 'new'
|
||||
|
@ -50,7 +50,7 @@ class ChannelGoogleAccountOverview extends App.ControllerSubContent
|
|||
constructor: ->
|
||||
super
|
||||
|
||||
#@interval(@load, 60000)
|
||||
@interval(@load, 30000)
|
||||
@load()
|
||||
|
||||
load: (reset_channel_id = false) =>
|
||||
|
@ -189,7 +189,7 @@ class ChannelGoogleAccountOverview extends App.ControllerSubContent
|
|||
e.preventDefault()
|
||||
channel_id = $(e.target).closest('.action').data('id')
|
||||
item = App.Channel.find(channel_id)
|
||||
new App.ChannelInboundEdit(
|
||||
new ChannelInboundEdit(
|
||||
container: @el.closest('.content')
|
||||
item: item
|
||||
callback: @load
|
||||
|
@ -220,7 +220,7 @@ class ChannelGoogleAccountOverview extends App.ControllerSubContent
|
|||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
item = App.Channel.find(id)
|
||||
new App.ChannelGroupEdit(
|
||||
new ChannelGroupEdit(
|
||||
container: @el.closest('.content')
|
||||
item: item
|
||||
callback: @load
|
||||
|
@ -261,7 +261,7 @@ class ChannelGoogleAccountOverview extends App.ControllerSubContent
|
|||
callback: @load
|
||||
)
|
||||
|
||||
class App.ChannelInboundEdit extends App.ControllerModal
|
||||
class ChannelInboundEdit extends App.ControllerModal
|
||||
buttonClose: true
|
||||
buttonCancel: true
|
||||
buttonSubmit: true
|
||||
|
@ -321,7 +321,7 @@ class App.ChannelInboundEdit extends App.ControllerModal
|
|||
timeout: 6000
|
||||
)
|
||||
|
||||
class App.ChannelGroupEdit extends App.ControllerModal
|
||||
class ChannelGroupEdit extends App.ControllerModal
|
||||
buttonClose: true
|
||||
buttonCancel: true
|
||||
buttonSubmit: true
|
||||
|
|
|
@ -10,7 +10,7 @@ class App.ChannelOffice365 extends App.ControllerTabs
|
|||
{
|
||||
name: 'Accounts',
|
||||
target: 'c-account',
|
||||
controller: ChannelOffice365AccountOverview,
|
||||
controller: ChannelAccountOverview,
|
||||
},
|
||||
{
|
||||
name: 'Filter',
|
||||
|
@ -32,7 +32,7 @@ class App.ChannelOffice365 extends App.ControllerTabs
|
|||
|
||||
@render()
|
||||
|
||||
class ChannelOffice365AccountOverview extends App.ControllerSubContent
|
||||
class ChannelAccountOverview extends App.ControllerSubContent
|
||||
requiredPermission: 'admin.channel_office365'
|
||||
events:
|
||||
'click .js-new': 'new'
|
||||
|
@ -50,7 +50,7 @@ class ChannelOffice365AccountOverview extends App.ControllerSubContent
|
|||
constructor: ->
|
||||
super
|
||||
|
||||
#@interval(@load, 60000)
|
||||
@interval(@load, 30000)
|
||||
@load()
|
||||
|
||||
load: (reset_channel_id = false) =>
|
||||
|
@ -180,7 +180,7 @@ class ChannelOffice365AccountOverview extends App.ControllerSubContent
|
|||
e.preventDefault()
|
||||
channel_id = $(e.target).closest('.action').data('id')
|
||||
item = App.Channel.find(channel_id)
|
||||
new App.ChannelInboundEdit(
|
||||
new ChannelInboundEdit(
|
||||
container: @el.closest('.content')
|
||||
item: item
|
||||
callback: @load
|
||||
|
@ -211,7 +211,7 @@ class ChannelOffice365AccountOverview extends App.ControllerSubContent
|
|||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
item = App.Channel.find(id)
|
||||
new App.ChannelGroupEdit(
|
||||
new ChannelGroupEdit(
|
||||
container: @el.closest('.content')
|
||||
item: item
|
||||
callback: @load
|
||||
|
@ -252,7 +252,7 @@ class ChannelOffice365AccountOverview extends App.ControllerSubContent
|
|||
callback: @load
|
||||
)
|
||||
|
||||
class App.ChannelInboundEdit extends App.ControllerModal
|
||||
class ChannelInboundEdit extends App.ControllerModal
|
||||
buttonClose: true
|
||||
buttonCancel: true
|
||||
buttonSubmit: true
|
||||
|
@ -312,7 +312,7 @@ class App.ChannelInboundEdit extends App.ControllerModal
|
|||
timeout: 6000
|
||||
)
|
||||
|
||||
class App.ChannelGroupEdit extends App.ControllerModal
|
||||
class ChannelGroupEdit extends App.ControllerModal
|
||||
buttonClose: true
|
||||
buttonCancel: true
|
||||
buttonSubmit: true
|
||||
|
|
|
@ -107,16 +107,17 @@ class ExternalCredential::Office365
|
|||
return migrate_channel
|
||||
end
|
||||
|
||||
email_addresses = user_aliases(response)
|
||||
email_addresses.unshift({
|
||||
email_addresses = [
|
||||
{
|
||||
realname: "#{Setting.get('product_name')} Support",
|
||||
email: user_data[:preferred_username],
|
||||
})
|
||||
},
|
||||
]
|
||||
|
||||
email_addresses.each do |email|
|
||||
next if !EmailAddress.exists?(email: email[:preferred_username])
|
||||
next if !EmailAddress.exists?(email: email[:email])
|
||||
|
||||
raise Exceptions::UnprocessableEntity, "Duplicate email address or email alias #{email[:preferred_username]} found!"
|
||||
raise Exceptions::UnprocessableEntity, "Duplicate email address or email alias #{email[:email]} found!"
|
||||
end
|
||||
|
||||
# create channel
|
||||
|
@ -226,37 +227,6 @@ class ExternalCredential::Office365
|
|||
).symbolize_keys
|
||||
end
|
||||
|
||||
def self.user_aliases(_token)
|
||||
# uri = URI.parse('https://www.office365apis.com/gmail/v1/users/me/settings/sendAs')
|
||||
# http = Net::HTTP.new(uri.host, uri.port)
|
||||
# http.use_ssl = true
|
||||
# response = http.get(uri.request_uri, { 'Authorization' => "#{token[:token_type]} #{token[:access_token]}" })
|
||||
# if response.code != 200 && response.body.blank?
|
||||
# Rails.logger.error "Request failed! (code: #{response.code})"
|
||||
# raise "Request failed! (code: #{response.code})"
|
||||
# end
|
||||
|
||||
# result = JSON.parse(response.body)
|
||||
# if result['error'] && response.code != 200
|
||||
# Rails.logger.error "Request failed! ERROR: #{result['error']['message']}"
|
||||
# raise "Request failed! ERROR: #{result['error']['message']}"
|
||||
# end
|
||||
|
||||
# aliases = []
|
||||
# result['sendAs'].each do |row|
|
||||
# next if row['isPrimary']
|
||||
# next if !row['verificationStatus']
|
||||
# next if row['verificationStatus'] != 'accepted'
|
||||
|
||||
# aliases.push({
|
||||
# realname: row['displayName'],
|
||||
# email: row['sendAsEmail'],
|
||||
# })
|
||||
# end
|
||||
|
||||
[]
|
||||
end
|
||||
|
||||
def self.user_info(id_token)
|
||||
split = id_token.split('.')[1]
|
||||
return if split.blank?
|
||||
|
|
Loading…
Reference in a new issue