Organize directories
This commit is contained in:
parent
8a91c9b89b
commit
4898382f78
433 changed files with 0 additions and 0 deletions
|
|
@ -0,0 +1,249 @@
|
|||
class Index extends App.ControllerSubContent
|
||||
requiredPermission: 'admin.channel_cdr_signal'
|
||||
events:
|
||||
'click .js-new': 'new'
|
||||
'click .js-edit': 'edit'
|
||||
'click .js-delete': 'delete'
|
||||
'click .js-disable': 'disable'
|
||||
'click .js-enable': 'enable'
|
||||
'click .js-rotate-token': 'rotateToken'
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
|
||||
#@interval(@load, 60000)
|
||||
@load()
|
||||
|
||||
load: =>
|
||||
@startLoading()
|
||||
@ajax(
|
||||
id: 'cdr_signal_index'
|
||||
type: 'GET'
|
||||
url: "#{@apiPath}/channels_cdr_signal"
|
||||
processData: true
|
||||
success: (data) =>
|
||||
@stopLoading()
|
||||
App.Collection.loadAssets(data.assets)
|
||||
@render(data)
|
||||
)
|
||||
|
||||
render: (data) =>
|
||||
|
||||
channels = []
|
||||
for channel_id in data.channel_ids
|
||||
channel = App.Channel.find(channel_id)
|
||||
if channel && channel.options
|
||||
displayName = '-'
|
||||
if channel.group_id
|
||||
group = App.Group.find(channel.group_id)
|
||||
displayName = group.displayName()
|
||||
channel.options.groupName = displayName
|
||||
channels.push channel
|
||||
@html App.view('cdr_signal/index')(
|
||||
channels: channels
|
||||
)
|
||||
|
||||
new: (e) =>
|
||||
e.preventDefault()
|
||||
new FormAdd(
|
||||
container: @el.parents('.content')
|
||||
load: @load
|
||||
)
|
||||
|
||||
edit: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
channel = App.Channel.find(id)
|
||||
new FormEdit(
|
||||
channel: channel
|
||||
container: @el.parents('.content')
|
||||
load: @load
|
||||
)
|
||||
|
||||
delete: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
new App.ControllerConfirm(
|
||||
message: 'Sure?'
|
||||
callback: =>
|
||||
@ajax(
|
||||
id: 'cdr_signal_delete'
|
||||
type: 'DELETE'
|
||||
url: "#{@apiPath}/channels_cdr_signal"
|
||||
data: JSON.stringify(id: id)
|
||||
processData: true
|
||||
success: =>
|
||||
@load()
|
||||
)
|
||||
container: @el.closest('.content')
|
||||
)
|
||||
|
||||
rotateToken: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
|
||||
new App.ControllerConfirm(
|
||||
message: 'This will break the submission form!'
|
||||
buttonSubmit: 'Reset token'
|
||||
head: 'Reset the submission token?'
|
||||
callback: =>
|
||||
@ajax(
|
||||
id: 'cdr_signal_disable'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/channels_cdr_signal_rotate_token"
|
||||
data: JSON.stringify(id: id)
|
||||
processData: true
|
||||
success: =>
|
||||
@load()
|
||||
)
|
||||
container: @el.closest('.content')
|
||||
)
|
||||
disable: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
@ajax(
|
||||
id: 'cdr_signal_disable'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/channels_cdr_signal_disable"
|
||||
data: JSON.stringify(id: id)
|
||||
processData: true
|
||||
success: =>
|
||||
@load()
|
||||
)
|
||||
|
||||
enable: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
@ajax(
|
||||
id: 'cdr_signal_enable'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/channels_cdr_signal_enable"
|
||||
data: JSON.stringify(id: id)
|
||||
processData: true
|
||||
success: =>
|
||||
@load()
|
||||
)
|
||||
|
||||
class FormAdd extends App.ControllerModal
|
||||
head: 'Add Web Form'
|
||||
shown: true
|
||||
button: 'Add'
|
||||
buttonCancel: true
|
||||
small: true
|
||||
|
||||
content: ->
|
||||
content = $(App.view('cdr_signal/form_add')())
|
||||
createOrgSelection = (selected_id) ->
|
||||
return App.UiElement.select.render(
|
||||
name: 'organization_id'
|
||||
multiple: false
|
||||
limit: 100
|
||||
null: false
|
||||
relation: 'Organization'
|
||||
nulloption: true
|
||||
value: selected_id
|
||||
class: 'form-control--small'
|
||||
)
|
||||
createGroupSelection = (selected_id) ->
|
||||
return App.UiElement.select.render(
|
||||
name: 'group_id'
|
||||
multiple: false
|
||||
limit: 100
|
||||
null: false
|
||||
relation: 'Group'
|
||||
nulloption: true
|
||||
value: selected_id
|
||||
class: 'form-control--small'
|
||||
)
|
||||
|
||||
content.find('.js-select').on('click', (e) =>
|
||||
@selectAll(e)
|
||||
)
|
||||
content.find('.js-messagesGroup').replaceWith createGroupSelection(1)
|
||||
content.find('.js-organization').replaceWith createOrgSelection(null)
|
||||
content
|
||||
|
||||
onClosed: =>
|
||||
return if !@isChanged
|
||||
@isChanged = false
|
||||
@load()
|
||||
|
||||
onSubmit: (e) =>
|
||||
@formDisable(e)
|
||||
@ajax(
|
||||
id: 'cdr_signal_app_verify'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/channels_cdr_signal"
|
||||
data: JSON.stringify(@formParams())
|
||||
processData: true
|
||||
success: =>
|
||||
@isChanged = true
|
||||
@close()
|
||||
error: (xhr) =>
|
||||
data = JSON.parse(xhr.responseText)
|
||||
@formEnable(e)
|
||||
error_message = App.i18n.translateContent(data.error || 'Unable to save Web Form.')
|
||||
@el.find('.alert').removeClass('hidden').text(error_message)
|
||||
)
|
||||
|
||||
class FormEdit extends App.ControllerModal
|
||||
head: 'Web Form Info'
|
||||
shown: true
|
||||
buttonCancel: true
|
||||
|
||||
content: ->
|
||||
content = $(App.view('cdr_signal/form_edit')(channel: @channel))
|
||||
|
||||
createOrgSelection = (selected_id) ->
|
||||
return App.UiElement.select.render(
|
||||
name: 'organization_id'
|
||||
multiple: false
|
||||
limit: 100
|
||||
null: false
|
||||
relation: 'Organization'
|
||||
nulloption: true
|
||||
value: selected_id
|
||||
class: 'form-control--small'
|
||||
)
|
||||
createGroupSelection = (selected_id) ->
|
||||
return App.UiElement.select.render(
|
||||
name: 'group_id'
|
||||
multiple: false
|
||||
limit: 100
|
||||
null: false
|
||||
relation: 'Group'
|
||||
nulloption: true
|
||||
value: selected_id
|
||||
class: 'form-control--small'
|
||||
)
|
||||
|
||||
content.find('.js-messagesGroup').replaceWith createGroupSelection(@channel.group_id)
|
||||
content.find('.js-organization').replaceWith createOrgSelection(@channel.options.organization_id)
|
||||
content
|
||||
|
||||
onClosed: =>
|
||||
return if !@isChanged
|
||||
@isChanged = false
|
||||
@load()
|
||||
|
||||
onSubmit: (e) =>
|
||||
@formDisable(e)
|
||||
params = @formParams()
|
||||
@channel.options = params
|
||||
@ajax(
|
||||
id: 'channel_cdr_signal_update'
|
||||
type: 'PUT'
|
||||
url: "#{@apiPath}/channels_cdr_signal/#{@channel.id}"
|
||||
data: JSON.stringify(@formParams())
|
||||
processData: true
|
||||
success: =>
|
||||
@isChanged = true
|
||||
@close()
|
||||
error: (xhr) =>
|
||||
data = JSON.parse(xhr.responseText)
|
||||
@formEnable(e)
|
||||
error_message = App.i18n.translateContent(data.error || 'Unable to save changes.')
|
||||
@el.find('.alert').removeClass('hidden').text(error_message)
|
||||
)
|
||||
|
||||
App.Config.set('cdr_signal', { prio: 5100, name: 'Signal', parent: '#channels', target: '#channels/cdr_signal', controller: Index, permission: ['admin.channel_cdr_signal'] }, 'NavBarAdmin')
|
||||
|
|
@ -0,0 +1,249 @@
|
|||
class Index extends App.ControllerSubContent
|
||||
requiredPermission: 'admin.channel_cdr_voice'
|
||||
events:
|
||||
'click .js-new': 'new'
|
||||
'click .js-edit': 'edit'
|
||||
'click .js-delete': 'delete'
|
||||
'click .js-disable': 'disable'
|
||||
'click .js-enable': 'enable'
|
||||
'click .js-rotate-token': 'rotateToken'
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
|
||||
#@interval(@load, 60000)
|
||||
@load()
|
||||
|
||||
load: =>
|
||||
@startLoading()
|
||||
@ajax(
|
||||
id: 'cdr_voice_index'
|
||||
type: 'GET'
|
||||
url: "#{@apiPath}/channels_cdr_voice"
|
||||
processData: true
|
||||
success: (data) =>
|
||||
@stopLoading()
|
||||
App.Collection.loadAssets(data.assets)
|
||||
@render(data)
|
||||
)
|
||||
|
||||
render: (data) =>
|
||||
|
||||
channels = []
|
||||
for channel_id in data.channel_ids
|
||||
channel = App.Channel.find(channel_id)
|
||||
if channel && channel.options
|
||||
displayName = '-'
|
||||
if channel.group_id
|
||||
group = App.Group.find(channel.group_id)
|
||||
displayName = group.displayName()
|
||||
channel.options.groupName = displayName
|
||||
channels.push channel
|
||||
@html App.view('cdr_voice/index')(
|
||||
channels: channels
|
||||
)
|
||||
|
||||
new: (e) =>
|
||||
e.preventDefault()
|
||||
new FormAdd(
|
||||
container: @el.parents('.content')
|
||||
load: @load
|
||||
)
|
||||
|
||||
edit: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
channel = App.Channel.find(id)
|
||||
new FormEdit(
|
||||
channel: channel
|
||||
container: @el.parents('.content')
|
||||
load: @load
|
||||
)
|
||||
|
||||
delete: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
new App.ControllerConfirm(
|
||||
message: 'Sure?'
|
||||
callback: =>
|
||||
@ajax(
|
||||
id: 'cdr_voice_delete'
|
||||
type: 'DELETE'
|
||||
url: "#{@apiPath}/channels_cdr_voice"
|
||||
data: JSON.stringify(id: id)
|
||||
processData: true
|
||||
success: =>
|
||||
@load()
|
||||
)
|
||||
container: @el.closest('.content')
|
||||
)
|
||||
|
||||
rotateToken: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
|
||||
new App.ControllerConfirm(
|
||||
message: 'This will break the submission form!'
|
||||
buttonSubmit: 'Reset token'
|
||||
head: 'Reset the submission token?'
|
||||
callback: =>
|
||||
@ajax(
|
||||
id: 'cdr_voice_disable'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/channels_cdr_voice_rotate_token"
|
||||
data: JSON.stringify(id: id)
|
||||
processData: true
|
||||
success: =>
|
||||
@load()
|
||||
)
|
||||
container: @el.closest('.content')
|
||||
)
|
||||
disable: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
@ajax(
|
||||
id: 'cdr_voice_disable'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/channels_cdr_voice_disable"
|
||||
data: JSON.stringify(id: id)
|
||||
processData: true
|
||||
success: =>
|
||||
@load()
|
||||
)
|
||||
|
||||
enable: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
@ajax(
|
||||
id: 'cdr_voice_enable'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/channels_cdr_voice_enable"
|
||||
data: JSON.stringify(id: id)
|
||||
processData: true
|
||||
success: =>
|
||||
@load()
|
||||
)
|
||||
|
||||
class FormAdd extends App.ControllerModal
|
||||
head: 'Add Web Form'
|
||||
shown: true
|
||||
button: 'Add'
|
||||
buttonCancel: true
|
||||
small: true
|
||||
|
||||
content: ->
|
||||
content = $(App.view('cdr_voice/form_add')())
|
||||
createOrgSelection = (selected_id) ->
|
||||
return App.UiElement.select.render(
|
||||
name: 'organization_id'
|
||||
multiple: false
|
||||
limit: 100
|
||||
null: false
|
||||
relation: 'Organization'
|
||||
nulloption: true
|
||||
value: selected_id
|
||||
class: 'form-control--small'
|
||||
)
|
||||
createGroupSelection = (selected_id) ->
|
||||
return App.UiElement.select.render(
|
||||
name: 'group_id'
|
||||
multiple: false
|
||||
limit: 100
|
||||
null: false
|
||||
relation: 'Group'
|
||||
nulloption: true
|
||||
value: selected_id
|
||||
class: 'form-control--small'
|
||||
)
|
||||
|
||||
content.find('.js-select').on('click', (e) =>
|
||||
@selectAll(e)
|
||||
)
|
||||
content.find('.js-messagesGroup').replaceWith createGroupSelection(1)
|
||||
content.find('.js-organization').replaceWith createOrgSelection(null)
|
||||
content
|
||||
|
||||
onClosed: =>
|
||||
return if !@isChanged
|
||||
@isChanged = false
|
||||
@load()
|
||||
|
||||
onSubmit: (e) =>
|
||||
@formDisable(e)
|
||||
@ajax(
|
||||
id: 'cdr_voice_app_verify'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/channels_cdr_voice"
|
||||
data: JSON.stringify(@formParams())
|
||||
processData: true
|
||||
success: =>
|
||||
@isChanged = true
|
||||
@close()
|
||||
error: (xhr) =>
|
||||
data = JSON.parse(xhr.responseText)
|
||||
@formEnable(e)
|
||||
error_message = App.i18n.translateContent(data.error || 'Unable to save Web Form.')
|
||||
@el.find('.alert').removeClass('hidden').text(error_message)
|
||||
)
|
||||
|
||||
class FormEdit extends App.ControllerModal
|
||||
head: 'Web Form Info'
|
||||
shown: true
|
||||
buttonCancel: true
|
||||
|
||||
content: ->
|
||||
content = $(App.view('cdr_voice/form_edit')(channel: @channel))
|
||||
|
||||
createOrgSelection = (selected_id) ->
|
||||
return App.UiElement.select.render(
|
||||
name: 'organization_id'
|
||||
multiple: false
|
||||
limit: 100
|
||||
null: false
|
||||
relation: 'Organization'
|
||||
nulloption: true
|
||||
value: selected_id
|
||||
class: 'form-control--small'
|
||||
)
|
||||
createGroupSelection = (selected_id) ->
|
||||
return App.UiElement.select.render(
|
||||
name: 'group_id'
|
||||
multiple: false
|
||||
limit: 100
|
||||
null: false
|
||||
relation: 'Group'
|
||||
nulloption: true
|
||||
value: selected_id
|
||||
class: 'form-control--small'
|
||||
)
|
||||
|
||||
content.find('.js-messagesGroup').replaceWith createGroupSelection(@channel.group_id)
|
||||
content.find('.js-organization').replaceWith createOrgSelection(@channel.options.organization_id)
|
||||
content
|
||||
|
||||
onClosed: =>
|
||||
return if !@isChanged
|
||||
@isChanged = false
|
||||
@load()
|
||||
|
||||
onSubmit: (e) =>
|
||||
@formDisable(e)
|
||||
params = @formParams()
|
||||
@channel.options = params
|
||||
@ajax(
|
||||
id: 'channel_cdr_voice_update'
|
||||
type: 'PUT'
|
||||
url: "#{@apiPath}/channels_cdr_voice/#{@channel.id}"
|
||||
data: JSON.stringify(@formParams())
|
||||
processData: true
|
||||
success: =>
|
||||
@isChanged = true
|
||||
@close()
|
||||
error: (xhr) =>
|
||||
data = JSON.parse(xhr.responseText)
|
||||
@formEnable(e)
|
||||
error_message = App.i18n.translateContent(data.error || 'Unable to save changes.')
|
||||
@el.find('.alert').removeClass('hidden').text(error_message)
|
||||
)
|
||||
|
||||
App.Config.set('cdr_voice', { prio: 5100, name: 'Voice', parent: '#channels', target: '#channels/cdr_voice', controller: Index, permission: ['admin.channel_cdr_voice'] }, 'NavBarAdmin')
|
||||
|
|
@ -0,0 +1,249 @@
|
|||
class Index extends App.ControllerSubContent
|
||||
requiredPermission: 'admin.channel_cdr_whatsapp'
|
||||
events:
|
||||
'click .js-new': 'new'
|
||||
'click .js-edit': 'edit'
|
||||
'click .js-delete': 'delete'
|
||||
'click .js-disable': 'disable'
|
||||
'click .js-enable': 'enable'
|
||||
'click .js-rotate-token': 'rotateToken'
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
|
||||
#@interval(@load, 60000)
|
||||
@load()
|
||||
|
||||
load: =>
|
||||
@startLoading()
|
||||
@ajax(
|
||||
id: 'cdr_whatsapp_index'
|
||||
type: 'GET'
|
||||
url: "#{@apiPath}/channels_cdr_whatsapp"
|
||||
processData: true
|
||||
success: (data) =>
|
||||
@stopLoading()
|
||||
App.Collection.loadAssets(data.assets)
|
||||
@render(data)
|
||||
)
|
||||
|
||||
render: (data) =>
|
||||
|
||||
channels = []
|
||||
for channel_id in data.channel_ids
|
||||
channel = App.Channel.find(channel_id)
|
||||
if channel && channel.options
|
||||
displayName = '-'
|
||||
if channel.group_id
|
||||
group = App.Group.find(channel.group_id)
|
||||
displayName = group.displayName()
|
||||
channel.options.groupName = displayName
|
||||
channels.push channel
|
||||
@html App.view('cdr_whatsapp/index')(
|
||||
channels: channels
|
||||
)
|
||||
|
||||
new: (e) =>
|
||||
e.preventDefault()
|
||||
new FormAdd(
|
||||
container: @el.parents('.content')
|
||||
load: @load
|
||||
)
|
||||
|
||||
edit: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
channel = App.Channel.find(id)
|
||||
new FormEdit(
|
||||
channel: channel
|
||||
container: @el.parents('.content')
|
||||
load: @load
|
||||
)
|
||||
|
||||
delete: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
new App.ControllerConfirm(
|
||||
message: 'Sure?'
|
||||
callback: =>
|
||||
@ajax(
|
||||
id: 'cdr_whatsapp_delete'
|
||||
type: 'DELETE'
|
||||
url: "#{@apiPath}/channels_cdr_whatsapp"
|
||||
data: JSON.stringify(id: id)
|
||||
processData: true
|
||||
success: =>
|
||||
@load()
|
||||
)
|
||||
container: @el.closest('.content')
|
||||
)
|
||||
|
||||
rotateToken: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
|
||||
new App.ControllerConfirm(
|
||||
message: 'This will break the submission form!'
|
||||
buttonSubmit: 'Reset token'
|
||||
head: 'Reset the submission token?'
|
||||
callback: =>
|
||||
@ajax(
|
||||
id: 'cdr_whatsapp_disable'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/channels_cdr_whatsapp_rotate_token"
|
||||
data: JSON.stringify(id: id)
|
||||
processData: true
|
||||
success: =>
|
||||
@load()
|
||||
)
|
||||
container: @el.closest('.content')
|
||||
)
|
||||
disable: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
@ajax(
|
||||
id: 'cdr_whatsapp_disable'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/channels_cdr_whatsapp_disable"
|
||||
data: JSON.stringify(id: id)
|
||||
processData: true
|
||||
success: =>
|
||||
@load()
|
||||
)
|
||||
|
||||
enable: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.target).closest('.action').data('id')
|
||||
@ajax(
|
||||
id: 'cdr_whatsapp_enable'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/channels_cdr_whatsapp_enable"
|
||||
data: JSON.stringify(id: id)
|
||||
processData: true
|
||||
success: =>
|
||||
@load()
|
||||
)
|
||||
|
||||
class FormAdd extends App.ControllerModal
|
||||
head: 'Add Web Form'
|
||||
shown: true
|
||||
button: 'Add'
|
||||
buttonCancel: true
|
||||
small: true
|
||||
|
||||
content: ->
|
||||
content = $(App.view('cdr_whatsapp/form_add')())
|
||||
createOrgSelection = (selected_id) ->
|
||||
return App.UiElement.select.render(
|
||||
name: 'organization_id'
|
||||
multiple: false
|
||||
limit: 100
|
||||
null: false
|
||||
relation: 'Organization'
|
||||
nulloption: true
|
||||
value: selected_id
|
||||
class: 'form-control--small'
|
||||
)
|
||||
createGroupSelection = (selected_id) ->
|
||||
return App.UiElement.select.render(
|
||||
name: 'group_id'
|
||||
multiple: false
|
||||
limit: 100
|
||||
null: false
|
||||
relation: 'Group'
|
||||
nulloption: true
|
||||
value: selected_id
|
||||
class: 'form-control--small'
|
||||
)
|
||||
|
||||
content.find('.js-select').on('click', (e) =>
|
||||
@selectAll(e)
|
||||
)
|
||||
content.find('.js-messagesGroup').replaceWith createGroupSelection(1)
|
||||
content.find('.js-organization').replaceWith createOrgSelection(null)
|
||||
content
|
||||
|
||||
onClosed: =>
|
||||
return if !@isChanged
|
||||
@isChanged = false
|
||||
@load()
|
||||
|
||||
onSubmit: (e) =>
|
||||
@formDisable(e)
|
||||
@ajax(
|
||||
id: 'cdr_whatsapp_app_verify'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/channels_cdr_whatsapp"
|
||||
data: JSON.stringify(@formParams())
|
||||
processData: true
|
||||
success: =>
|
||||
@isChanged = true
|
||||
@close()
|
||||
error: (xhr) =>
|
||||
data = JSON.parse(xhr.responseText)
|
||||
@formEnable(e)
|
||||
error_message = App.i18n.translateContent(data.error || 'Unable to save Web Form.')
|
||||
@el.find('.alert').removeClass('hidden').text(error_message)
|
||||
)
|
||||
|
||||
class FormEdit extends App.ControllerModal
|
||||
head: 'Web Form Info'
|
||||
shown: true
|
||||
buttonCancel: true
|
||||
|
||||
content: ->
|
||||
content = $(App.view('cdr_whatsapp/form_edit')(channel: @channel))
|
||||
|
||||
createOrgSelection = (selected_id) ->
|
||||
return App.UiElement.select.render(
|
||||
name: 'organization_id'
|
||||
multiple: false
|
||||
limit: 100
|
||||
null: false
|
||||
relation: 'Organization'
|
||||
nulloption: true
|
||||
value: selected_id
|
||||
class: 'form-control--small'
|
||||
)
|
||||
createGroupSelection = (selected_id) ->
|
||||
return App.UiElement.select.render(
|
||||
name: 'group_id'
|
||||
multiple: false
|
||||
limit: 100
|
||||
null: false
|
||||
relation: 'Group'
|
||||
nulloption: true
|
||||
value: selected_id
|
||||
class: 'form-control--small'
|
||||
)
|
||||
|
||||
content.find('.js-messagesGroup').replaceWith createGroupSelection(@channel.group_id)
|
||||
content.find('.js-organization').replaceWith createOrgSelection(@channel.options.organization_id)
|
||||
content
|
||||
|
||||
onClosed: =>
|
||||
return if !@isChanged
|
||||
@isChanged = false
|
||||
@load()
|
||||
|
||||
onSubmit: (e) =>
|
||||
@formDisable(e)
|
||||
params = @formParams()
|
||||
@channel.options = params
|
||||
@ajax(
|
||||
id: 'channel_cdr_whatsapp_update'
|
||||
type: 'PUT'
|
||||
url: "#{@apiPath}/channels_cdr_whatsapp/#{@channel.id}"
|
||||
data: JSON.stringify(@formParams())
|
||||
processData: true
|
||||
success: =>
|
||||
@isChanged = true
|
||||
@close()
|
||||
error: (xhr) =>
|
||||
data = JSON.parse(xhr.responseText)
|
||||
@formEnable(e)
|
||||
error_message = App.i18n.translateContent(data.error || 'Unable to save changes.')
|
||||
@el.find('.alert').removeClass('hidden').text(error_message)
|
||||
)
|
||||
|
||||
App.Config.set('cdr_whatsapp', { prio: 5100, name: 'Whatsapp', parent: '#channels', target: '#channels/cdr_whatsapp', controller: Index, permission: ['admin.channel_cdr_whatsapp'] }, 'NavBarAdmin')
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
class CdrSignalReply
|
||||
@action: (actions, ticket, article, ui) ->
|
||||
return actions if ui.permissionCheck('ticket.customer')
|
||||
|
||||
if article.sender.name is 'Customer' && article.type.name is 'cdr_signal'
|
||||
actions.push {
|
||||
name: 'reply'
|
||||
type: 'cdrSignalMessageReply'
|
||||
icon: 'reply'
|
||||
href: '#'
|
||||
}
|
||||
|
||||
actions
|
||||
|
||||
@perform: (articleContainer, type, ticket, article, ui) ->
|
||||
return true if type isnt 'cdrSignalMessageReply'
|
||||
|
||||
ui.scrollToCompose()
|
||||
|
||||
# get reference article
|
||||
type = App.TicketArticleType.find(article.type_id)
|
||||
|
||||
articleNew = {
|
||||
to: ''
|
||||
cc: ''
|
||||
body: ''
|
||||
in_reply_to: ''
|
||||
}
|
||||
|
||||
if article.message_id
|
||||
articleNew.in_reply_to = article.message_id
|
||||
|
||||
# get current body
|
||||
articleNew.body = ui.el.closest('.ticketZoom').find('.article-add [data-name="body"]').html().trim() || ''
|
||||
|
||||
App.Event.trigger('ui::ticket::setArticleType', {
|
||||
ticket: ticket
|
||||
type: type
|
||||
article: articleNew
|
||||
position: 'end'
|
||||
})
|
||||
|
||||
true
|
||||
|
||||
@articleTypes: (articleTypes, ticket, ui) ->
|
||||
return articleTypes if !ui.permissionCheck('ticket.agent')
|
||||
|
||||
return articleTypes if !ticket || !ticket.create_article_type_id
|
||||
|
||||
articleTypeCreate = App.TicketArticleType.find(ticket.create_article_type_id).name
|
||||
|
||||
return articleTypes if articleTypeCreate isnt 'cdr_signal'
|
||||
articleTypes.push {
|
||||
name: 'cdr_signal'
|
||||
icon: 'cdr-signal'
|
||||
attributes: []
|
||||
internal: false,
|
||||
features: ['attachment']
|
||||
maxTextLength: 10000
|
||||
warningTextLength: 5000
|
||||
}
|
||||
articleTypes
|
||||
|
||||
@setArticleTypePost: (type, ticket, ui) ->
|
||||
return if type isnt 'cdr_signal'
|
||||
rawHTML = ui.$('[data-name=body]').html()
|
||||
cleanHTML = App.Utils.htmlRemoveRichtext(rawHTML)
|
||||
if cleanHTML && cleanHTML.html() != rawHTML
|
||||
ui.$('[data-name=body]').html(cleanHTML)
|
||||
|
||||
@params: (type, params, ui) ->
|
||||
if type is 'cdr_signal'
|
||||
App.Utils.htmlRemoveRichtext(ui.$('[data-name=body]'), false)
|
||||
params.content_type = 'text/plain'
|
||||
params.body = App.Utils.html2text(params.body, true)
|
||||
|
||||
params
|
||||
|
||||
App.Config.set('300-CdrSignalReply', CdrSignalReply, 'TicketZoomArticleAction')
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
class CdrWhatsappReply
|
||||
@action: (actions, ticket, article, ui) ->
|
||||
return actions if ui.permissionCheck('ticket.customer')
|
||||
|
||||
if article.sender.name is 'Customer' && article.type.name is 'cdr_whatsapp'
|
||||
actions.push {
|
||||
name: 'reply'
|
||||
type: 'cdrWhatsappMessageReply'
|
||||
icon: 'reply'
|
||||
href: '#'
|
||||
}
|
||||
|
||||
actions
|
||||
|
||||
@perform: (articleContainer, type, ticket, article, ui) ->
|
||||
return true if type isnt 'cdrWhatsappMessageReply'
|
||||
|
||||
ui.scrollToCompose()
|
||||
|
||||
# get reference article
|
||||
type = App.TicketArticleType.find(article.type_id)
|
||||
|
||||
articleNew = {
|
||||
to: ''
|
||||
cc: ''
|
||||
body: ''
|
||||
in_reply_to: ''
|
||||
}
|
||||
|
||||
if article.message_id
|
||||
articleNew.in_reply_to = article.message_id
|
||||
|
||||
# get current body
|
||||
articleNew.body = ui.el.closest('.ticketZoom').find('.article-add [data-name="body"]').html().trim() || ''
|
||||
|
||||
App.Event.trigger('ui::ticket::setArticleType', {
|
||||
ticket: ticket
|
||||
type: type
|
||||
article: articleNew
|
||||
position: 'end'
|
||||
})
|
||||
|
||||
true
|
||||
|
||||
@articleTypes: (articleTypes, ticket, ui) ->
|
||||
return articleTypes if !ui.permissionCheck('ticket.agent')
|
||||
|
||||
return articleTypes if !ticket || !ticket.create_article_type_id
|
||||
|
||||
articleTypeCreate = App.TicketArticleType.find(ticket.create_article_type_id).name
|
||||
|
||||
return articleTypes if articleTypeCreate isnt 'cdr_whatsapp'
|
||||
articleTypes.push {
|
||||
name: 'cdr_whatsapp'
|
||||
icon: 'cdr-whatsapp'
|
||||
attributes: []
|
||||
internal: false,
|
||||
features: ['attachment']
|
||||
maxTextLength: 10000
|
||||
warningTextLength: 5000
|
||||
}
|
||||
articleTypes
|
||||
|
||||
@setArticleTypePost: (type, ticket, ui) ->
|
||||
return if type isnt 'cdr_whatsapp'
|
||||
rawHTML = ui.$('[data-name=body]').html()
|
||||
cleanHTML = App.Utils.htmlRemoveRichtext(rawHTML)
|
||||
if cleanHTML && cleanHTML.html() != rawHTML
|
||||
ui.$('[data-name=body]').html(cleanHTML)
|
||||
|
||||
@params: (type, params, ui) ->
|
||||
if type is 'cdr_whatsapp'
|
||||
App.Utils.htmlRemoveRichtext(ui.$('[data-name=body]'), false)
|
||||
params.content_type = 'text/plain'
|
||||
params.body = App.Utils.html2text(params.body, true)
|
||||
|
||||
params
|
||||
|
||||
App.Config.set('300-CdrWhatsappReply', CdrWhatsappReply, 'TicketZoomArticleAction')
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<div class="alert alert--danger hidden" role="alert"></div>
|
||||
<fieldset>
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="form_name"><%- @T('Phone number') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="phone_number" type="text" name="phone_number" value="" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="form_name"><%- @T('Bot Token') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="bot_token" type="text" name="bot_token" value="" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="form_name"><%- @T('Bot Endpoint') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="bot_endpoint" type="text" name="bot_endpoint" value="" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for=""><%- @T('Choose the group in which form submissions will get added to.') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="js-messagesGroup"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for=""><%- @T('Choose the organization to which submitters will be added to when they submit via this form.') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="profile-organization js-organization"></div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<div class="alert alert--danger hidden" role="alert"></div>
|
||||
|
||||
<fieldset>
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="form_name"><%- @T('Voice Line Number') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="phone_number" type="text" name="phone_number" value="<%= @channel.options.phone_number %>" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="form_name"><%- @T('Bot Token') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="bot_token" type="text" name="bot_token" value="<%= @channel.options.bot_token %>" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="form_name"><%- @T('Bot Endpoint') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="bot_endpoint" type="text" name="bot_endpoint" value="<%= @channel.options.bot_endpoint %>" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for=""><%- @T('Choose the group in which incoming messages will be added.') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="js-messagesGroup"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for=""><%- @T('Choose the organization to which users will be added to when they send a message to this number.') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="profile-organization js-organization"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="token"><%- @T('Endpoint URL') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="token" type="text" value="<%= "#{App.Config.get('http_type')}://#{App.Config.get('fqdn')}/api/v1/channels_cdr_signal_webhook/#{@channel.options.token}" %>" class="form-control input js-select" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<div class="page-header">
|
||||
<div class="page-header-title">
|
||||
<h1><%- @T('Signal') %></h1>
|
||||
</div>
|
||||
|
||||
<div class="page-header-meta">
|
||||
<a class="btn btn--success js-new"><%- @T('Add Signal bot') %></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-content">
|
||||
|
||||
<% if _.isEmpty(@channels): %>
|
||||
<div class="page-description">
|
||||
<p><%- @T('You have no configured %s right now.', 'Signal numbers') %></p>
|
||||
</div>
|
||||
<% else: %>
|
||||
|
||||
<% for channel in @channels: %>
|
||||
<div class="action <% if channel.active isnt true: %>is-inactive<% end %>" data-id="<%= channel.id %>">
|
||||
<div class="action-block action-row">
|
||||
<h2><%- @Icon('status', 'supergood-color inline') %> <%= channel.options.phone_number %></h2>
|
||||
</div>
|
||||
<div class="action-flow action-flow--row">
|
||||
<div class="action-block">
|
||||
<h3><%- @T('Group') %></h3>
|
||||
<% if channel.options: %>
|
||||
<%= channel.options.groupName %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="action-block">
|
||||
<h3><%- @T('Endpoint URL') %></h3>
|
||||
<%- @T('Click the edit button to view the endpoint details ') %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="action-controls">
|
||||
<div class="btn btn--danger btn--secondary js-delete"><%- @T('Delete') %></div>
|
||||
<div class="btn btn--danger btn--secondary js-rotate-token"><%- @T('Reset Token') %></div>
|
||||
<% if channel.active is true: %>
|
||||
<div class="btn btn--secondary js-disable"><%- @T('Disable') %></div>
|
||||
<% else: %>
|
||||
<div class="btn btn--secondary js-enable"><%- @T('Enable') %></div>
|
||||
<% end %>
|
||||
<div class="btn js-edit"><%- @T('Edit') %></div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<div class="alert alert--danger hidden" role="alert"></div>
|
||||
<fieldset>
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="form_name"><%- @T('Phone number') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="phone_number" type="text" name="phone_number" value="" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for=""><%- @T('Choose the group in which form submissions will get added to.') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="js-messagesGroup"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for=""><%- @T('Choose the organization to which submitters will be added to when they submit via this form.') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="profile-organization js-organization"></div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<div class="alert alert--danger hidden" role="alert"></div>
|
||||
|
||||
<fieldset>
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="form_name"><%- @T('Voice Line Number') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="phone_number" type="text" name="phone_number" value="<%= @channel.options.phone_number %>" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for=""><%- @T('Choose the group in which incoming calls will be added to.') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="js-messagesGroup"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for=""><%- @T('Choose the organization to which users will be added to when they leave a recording to this voice line.') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="profile-organization js-organization"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="token"><%- @T('Endpoint URL') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="token" type="text" value="<%= "#{App.Config.get('http_type')}://#{App.Config.get('fqdn')}/api/v1/channels_cdr_voice_webhook/#{@channel.options.token}" %>" class="form-control input js-select" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<div class="page-header">
|
||||
<div class="page-header-title">
|
||||
<h1><%- @T('Voice') %></h1>
|
||||
</div>
|
||||
|
||||
<div class="page-header-meta">
|
||||
<a class="btn btn--success js-new"><%- @T('Add Voice Line') %></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-content">
|
||||
|
||||
<% if _.isEmpty(@channels): %>
|
||||
<div class="page-description">
|
||||
<p><%- @T('You have no configured %s right now.', 'voice lines') %></p>
|
||||
</div>
|
||||
<% else: %>
|
||||
|
||||
<% for channel in @channels: %>
|
||||
<div class="action <% if channel.active isnt true: %>is-inactive<% end %>" data-id="<%= channel.id %>">
|
||||
<div class="action-block action-row">
|
||||
<h2><%- @Icon('status', 'supergood-color inline') %> <%= channel.options.phone_number %></h2>
|
||||
</div>
|
||||
<div class="action-flow action-flow--row">
|
||||
<div class="action-block">
|
||||
<h3><%- @T('Group') %></h3>
|
||||
<% if channel.options: %>
|
||||
<%= channel.options.groupName %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="action-block">
|
||||
<h3><%- @T('Endpoint URL') %></h3>
|
||||
<%- @T('Click the edit button to view the endpoint details ') %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="action-controls">
|
||||
<div class="btn btn--danger btn--secondary js-delete"><%- @T('Delete') %></div>
|
||||
<div class="btn btn--danger btn--secondary js-rotate-token"><%- @T('Reset Token') %></div>
|
||||
<% if channel.active is true: %>
|
||||
<div class="btn btn--secondary js-disable"><%- @T('Disable') %></div>
|
||||
<% else: %>
|
||||
<div class="btn btn--secondary js-enable"><%- @T('Enable') %></div>
|
||||
<% end %>
|
||||
<div class="btn js-edit"><%- @T('Edit') %></div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<div class="alert alert--danger hidden" role="alert"></div>
|
||||
<fieldset>
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="form_name"><%- @T('Phone number') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="phone_number" type="text" name="phone_number" value="" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="form_name"><%- @T('Bot Token') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="bot_token" type="text" name="bot_token" value="" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="form_name"><%- @T('Bot Endpoint') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="bot_endpoint" type="text" name="bot_endpoint" value="" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for=""><%- @T('Choose the group in which form submissions will get added to.') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="js-messagesGroup"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for=""><%- @T('Choose the organization to which submitters will be added to when they submit via this form.') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="profile-organization js-organization"></div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<div class="alert alert--danger hidden" role="alert"></div>
|
||||
|
||||
<fieldset>
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="form_name"><%- @T('Whatsapp Number') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="phone_number" type="text" name="phone_number" value="<%= @channel.options.phone_number %>" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="form_name"><%- @T('Bot Token') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="bot_token" type="text" name="bot_token" value="<%= @channel.options.bot_token %>" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="form_name"><%- @T('Bot Endpoint') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="bot_endpoint" type="text" name="bot_endpoint" value="<%= @channel.options.bot_endpoint %>" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for=""><%- @T('Choose the group in which incoming messages will be added to.') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="js-messagesGroup"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for=""><%- @T('Choose the organization to which users will be added to when they send a message to this number.') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="profile-organization js-organization"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="token"><%- @T('Endpoint URL') %> <span>*</span></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id="token" type="text" value="<%= "#{App.Config.get('http_type')}://#{App.Config.get('fqdn')}/api/v1/channels_cdr_whatsapp_webhook/#{@channel.options.token}" %>" class="form-control input js-select" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<div class="page-header">
|
||||
<div class="page-header-title">
|
||||
<h1><%- @T('Whatsapp') %></h1>
|
||||
</div>
|
||||
|
||||
<div class="page-header-meta">
|
||||
<a class="btn btn--success js-new"><%- @T('Add Whatsapp bot') %></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-content">
|
||||
|
||||
<% if _.isEmpty(@channels): %>
|
||||
<div class="page-description">
|
||||
<p><%- @T('You have no configured %s right now.', 'Whatsapp numbers') %></p>
|
||||
</div>
|
||||
<% else: %>
|
||||
|
||||
<% for channel in @channels: %>
|
||||
<div class="action <% if channel.active isnt true: %>is-inactive<% end %>" data-id="<%= channel.id %>">
|
||||
<div class="action-block action-row">
|
||||
<h2><%- @Icon('status', 'supergood-color inline') %> <%= channel.options.phone_number %></h2>
|
||||
</div>
|
||||
<div class="action-flow action-flow--row">
|
||||
<div class="action-block">
|
||||
<h3><%- @T('Group') %></h3>
|
||||
<% if channel.options: %>
|
||||
<%= channel.options.groupName %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="action-block">
|
||||
<h3><%- @T('Endpoint URL') %></h3>
|
||||
<%- @T('Click the edit button to view the endpoint details ') %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="action-controls">
|
||||
<div class="btn btn--danger btn--secondary js-delete"><%- @T('Delete') %></div>
|
||||
<div class="btn btn--danger btn--secondary js-rotate-token"><%- @T('Reset Token') %></div>
|
||||
<% if channel.active is true: %>
|
||||
<div class="btn btn--secondary js-disable"><%- @T('Disable') %></div>
|
||||
<% else: %>
|
||||
<div class="btn btn--secondary js-enable"><%- @T('Enable') %></div>
|
||||
<% end %>
|
||||
<div class="btn js-edit"><%- @T('Edit') %></div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
.icon-cdr-signal {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
.icon-cdr-whatsapp {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
}
|
||||
|
|
@ -0,0 +1,268 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ChannelsCdrSignalController < ApplicationController
|
||||
prepend_before_action -> { authentication_check && authorize! }, except: [:webhook]
|
||||
skip_before_action :verify_csrf_token, only: [:webhook]
|
||||
|
||||
include CreatesTicketArticles
|
||||
|
||||
def index
|
||||
assets = {}
|
||||
channel_ids = []
|
||||
Channel.where(area: 'Signal::Number').order(:id).each do |channel|
|
||||
assets = channel.assets(assets)
|
||||
channel_ids.push channel.id
|
||||
end
|
||||
render json: {
|
||||
assets: assets,
|
||||
channel_ids: channel_ids
|
||||
}
|
||||
end
|
||||
|
||||
def add
|
||||
begin
|
||||
errors = {}
|
||||
errors['group_id'] = 'required' unless params[:group_id].present?
|
||||
|
||||
if errors.present?
|
||||
render json: {
|
||||
errors: errors
|
||||
}, status: :bad_request
|
||||
return
|
||||
end
|
||||
channel = Channel.create(
|
||||
area: 'Signal::Number',
|
||||
options: {
|
||||
adapter: 'cdr_signal',
|
||||
phone_number: params[:phone_number],
|
||||
bot_token: params[:bot_token],
|
||||
bot_endpoint: params[:bot_endpoint],
|
||||
token: SecureRandom.urlsafe_base64(48),
|
||||
organization_id: params[:organization_id]
|
||||
},
|
||||
group_id: params[:group_id],
|
||||
active: true
|
||||
)
|
||||
rescue StandardError => e
|
||||
raise Exceptions::UnprocessableEntity, e.message
|
||||
end
|
||||
render json: channel
|
||||
end
|
||||
|
||||
def update
|
||||
errors = {}
|
||||
errors['group_id'] = 'required' unless params[:group_id].present?
|
||||
|
||||
if errors.present?
|
||||
render json: {
|
||||
errors: errors
|
||||
}, status: :bad_request
|
||||
return
|
||||
end
|
||||
channel = Channel.find_by(id: params[:id], area: 'Signal::Number')
|
||||
begin
|
||||
channel.options[:phone_number] = params[:phone_number]
|
||||
channel.options[:bot_token] = params[:bot_token]
|
||||
channel.options[:bot_endpoint] = params[:bot_endpoint]
|
||||
channel.options[:organization_id] = params[:organization_id]
|
||||
channel.group_id = params[:group_id]
|
||||
channel.save!
|
||||
rescue StandardError => e
|
||||
raise Exceptions::UnprocessableEntity, e.message
|
||||
end
|
||||
render json: channel
|
||||
end
|
||||
|
||||
def rotate_token
|
||||
channel = Channel.find_by(id: params[:id], area: 'Signal::Number')
|
||||
channel.options[:token] = SecureRandom.urlsafe_base64(48)
|
||||
channel.save!
|
||||
render json: {}
|
||||
end
|
||||
|
||||
def enable
|
||||
channel = Channel.find_by(id: params[:id], area: 'Signal::Number')
|
||||
channel.active = true
|
||||
channel.save!
|
||||
render json: {}
|
||||
end
|
||||
|
||||
def disable
|
||||
channel = Channel.find_by(id: params[:id], area: 'Signal::Number')
|
||||
channel.active = false
|
||||
channel.save!
|
||||
render json: {}
|
||||
end
|
||||
|
||||
def destroy
|
||||
channel = Channel.find_by(id: params[:id], area: 'Signal::Number')
|
||||
channel.destroy
|
||||
render json: {}
|
||||
end
|
||||
|
||||
def channel_for_token(token)
|
||||
return false unless token
|
||||
|
||||
Channel.where(area: 'Signal::Number').each do |channel|
|
||||
return channel if channel.options[:token] == token
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
def webhook
|
||||
token = params['token']
|
||||
return render json: {}, status: 401 unless token
|
||||
|
||||
channel = channel_for_token(token)
|
||||
return render json: {}, status: 401 if !channel || !channel.active
|
||||
return render json: {}, status: 401 if channel.options[:token] != token
|
||||
|
||||
channel_id = channel.id
|
||||
|
||||
# validate input
|
||||
errors = {}
|
||||
|
||||
# %i[to
|
||||
# from
|
||||
# message_id
|
||||
# sent_at].each | field |
|
||||
# (errors[field] = 'required' if params[field].blank?)
|
||||
|
||||
if errors.present?
|
||||
render json: {
|
||||
errors: errors
|
||||
}, status: :bad_request
|
||||
return
|
||||
end
|
||||
|
||||
message_id = params[:message_id]
|
||||
|
||||
return if Ticket::Article.exists?(message_id: "cdr_signal.#{message_id}")
|
||||
|
||||
receiver_phone_number = params[:to].strip
|
||||
sender_phone_number = params[:from].strip
|
||||
customer = User.find_by(phone: sender_phone_number)
|
||||
customer ||= User.find_by(mobile: sender_phone_number)
|
||||
unless customer
|
||||
role_ids = Role.signup_role_ids
|
||||
customer = User.create(
|
||||
firstname: '',
|
||||
lastname: '',
|
||||
email: '',
|
||||
password: '',
|
||||
phone: sender_phone_number,
|
||||
note: 'CDR Signal',
|
||||
active: true,
|
||||
role_ids: role_ids,
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1
|
||||
)
|
||||
end
|
||||
|
||||
# set current user
|
||||
UserInfo.current_user_id = customer.id
|
||||
current_user_set(customer, 'token_auth')
|
||||
|
||||
group = Group.find_by(id: channel.group_id)
|
||||
if group.blank?
|
||||
Rails.logger.error "Signal channel #{channel_id} paired with Group #{channel.group_id}, but group does not exist!"
|
||||
return render json: { error: 'There was an error during Signal submission' }, status: 500
|
||||
end
|
||||
|
||||
organization_id = channel.options['organization_id']
|
||||
if organization_id.present?
|
||||
organization = Organization.find_by(id: organization_id)
|
||||
unless organization.present?
|
||||
Rails.logger.error "Signal channel #{channel_id} paired with Organization #{organization_id}, but organization does not exist!"
|
||||
return render json: { error: 'There was an error during Signal submission' }, status: 500
|
||||
end
|
||||
unless customer.organization_id.present?
|
||||
customer.organization_id = organization.id
|
||||
customer.save!
|
||||
end
|
||||
end
|
||||
|
||||
message = params[:message] ||= 'No text content'
|
||||
sent_at = params[:sent_at]
|
||||
attachment_data_base64 = params[:attachment]
|
||||
attachment_filename = params[:filename]
|
||||
attachment_mimetype = params[:mime_type]
|
||||
title = "Message from #{sender_phone_number} at #{sent_at}"
|
||||
body = message
|
||||
|
||||
# find ticket or create one
|
||||
state_ids = Ticket::State.where(name: %w[closed merged removed]).pluck(:id)
|
||||
ticket = Ticket.where(customer_id: customer.id).where.not(state_id: state_ids).order(:updated_at).first
|
||||
if ticket
|
||||
# check if title need to be updated
|
||||
ticket.title = title if ticket.title == '-'
|
||||
new_state = Ticket::State.find_by(default_create: true)
|
||||
ticket.state = Ticket::State.find_by(default_follow_up: true) if ticket.state_id != new_state.id
|
||||
else
|
||||
ticket = Ticket.new(
|
||||
group_id: channel.group_id,
|
||||
title: title,
|
||||
customer_id: customer.id,
|
||||
preferences: {
|
||||
channel_id: channel.id,
|
||||
cdr_signal: {
|
||||
bot_token: channel.options[:bot_token], # change to bot id
|
||||
chat_id: sender_phone_number
|
||||
}
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
ticket.save!
|
||||
|
||||
article_params = {
|
||||
from: sender_phone_number,
|
||||
to: receiver_phone_number,
|
||||
sender_id: Ticket::Article::Sender.find_by(name: 'Customer').id,
|
||||
subject: title,
|
||||
body: body,
|
||||
content_type: 'text/plain',
|
||||
message_id: "cdr_signal.#{message_id}",
|
||||
ticket_id: ticket.id,
|
||||
internal: false,
|
||||
preferences: {
|
||||
cdr_signal: {
|
||||
timestamp: sent_at,
|
||||
message_id: message_id,
|
||||
from: sender_phone_number
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if attachment_data_base64.present?
|
||||
article_params[:attachments] = [
|
||||
# i don't even...
|
||||
# this is necessary because of what's going on in controllers/concerns/creates_ticket_articles.rb
|
||||
# we need help from the ruby gods
|
||||
{
|
||||
'filename' => attachment_filename,
|
||||
:filename => attachment_filename,
|
||||
:data => attachment_data_base64,
|
||||
'data' => attachment_data_base64,
|
||||
'mime-type' => attachment_mimetype
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
ticket.with_lock do
|
||||
ta = article_create(ticket, article_params)
|
||||
ta.update!(type_id: Ticket::Article::Type.find_by(name: 'cdr_signal').id)
|
||||
end
|
||||
|
||||
ticket.update!(create_article_type_id: Ticket::Article::Type.find_by(name: 'cdr_signal').id)
|
||||
|
||||
result = {
|
||||
ticket: {
|
||||
id: ticket.id,
|
||||
number: ticket.number
|
||||
}
|
||||
}
|
||||
|
||||
render json: result, status: :ok
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,253 @@
|
|||
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
class ChannelsCdrVoiceController < ApplicationController
|
||||
prepend_before_action -> { authentication_check && authorize! }, except: [:webhook]
|
||||
skip_before_action :verify_csrf_token, only: [:webhook]
|
||||
|
||||
include CreatesTicketArticles
|
||||
|
||||
def index
|
||||
assets = {}
|
||||
channel_ids = []
|
||||
Channel.where(area: 'Voice::Number').order(:id).each do |channel|
|
||||
assets = channel.assets(assets)
|
||||
channel_ids.push channel.id
|
||||
end
|
||||
render json: {
|
||||
assets: assets,
|
||||
channel_ids: channel_ids
|
||||
}
|
||||
end
|
||||
|
||||
def add
|
||||
begin
|
||||
errors = {}
|
||||
errors['group_id'] = 'required' unless params[:group_id].present?
|
||||
|
||||
if errors.present?
|
||||
render json: {
|
||||
errors: errors
|
||||
}, status: :bad_request
|
||||
return
|
||||
end
|
||||
channel = Channel.create(
|
||||
area: 'Voice::Number',
|
||||
options: {
|
||||
phone_number: params[:phone_number],
|
||||
token: SecureRandom.urlsafe_base64(48),
|
||||
organization_id: params[:organization_id]
|
||||
},
|
||||
group_id: params[:group_id],
|
||||
active: true
|
||||
)
|
||||
rescue StandardError => e
|
||||
raise Exceptions::UnprocessableEntity, e.message
|
||||
end
|
||||
render json: channel
|
||||
end
|
||||
|
||||
def update
|
||||
errors = {}
|
||||
errors['group_id'] = 'required' unless params[:group_id].present?
|
||||
|
||||
if errors.present?
|
||||
render json: {
|
||||
errors: errors
|
||||
}, status: :bad_request
|
||||
return
|
||||
end
|
||||
channel = Channel.find_by(id: params[:id], area: 'Voice::Number')
|
||||
begin
|
||||
channel.options[:phone_number] = params[:phone_number]
|
||||
channel.options[:organization_id] = params[:organization_id]
|
||||
channel.group_id = params[:group_id]
|
||||
channel.save!
|
||||
rescue StandardError => e
|
||||
raise Exceptions::UnprocessableEntity, e.message
|
||||
end
|
||||
render json: channel
|
||||
end
|
||||
|
||||
def rotate_token
|
||||
channel = Channel.find_by(id: params[:id], area: 'Voice::Number')
|
||||
channel.options[:token] = SecureRandom.urlsafe_base64(48)
|
||||
channel.save!
|
||||
render json: {}
|
||||
end
|
||||
|
||||
def enable
|
||||
channel = Channel.find_by(id: params[:id], area: 'Voice::Number')
|
||||
channel.active = true
|
||||
channel.save!
|
||||
render json: {}
|
||||
end
|
||||
|
||||
def disable
|
||||
channel = Channel.find_by(id: params[:id], area: 'Voice::Number')
|
||||
channel.active = false
|
||||
channel.save!
|
||||
render json: {}
|
||||
end
|
||||
|
||||
def destroy
|
||||
channel = Channel.find_by(id: params[:id], area: 'Voice::Number')
|
||||
channel.destroy
|
||||
render json: {}
|
||||
end
|
||||
|
||||
def channel_for_token(token)
|
||||
return false unless token
|
||||
|
||||
Channel.where(area: 'Voice::Number').each do |channel|
|
||||
return channel if channel.options[:token] == token
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
def webhook
|
||||
token = params['token']
|
||||
return render json: {}, status: 401 unless token
|
||||
|
||||
channel = channel_for_token(token)
|
||||
return render json: {}, status: 401 if !channel || !channel.active
|
||||
return render json: {}, status: 401 if channel.options[:token] != token
|
||||
|
||||
channel_id = channel.id
|
||||
|
||||
# validate input
|
||||
errors = {}
|
||||
|
||||
%i[to
|
||||
from
|
||||
duration
|
||||
startTime
|
||||
endTime
|
||||
recording
|
||||
mimeType
|
||||
callSid].each do |field|
|
||||
errors[field] = 'required' if params[field].blank?
|
||||
end
|
||||
|
||||
valid_mimetypes = ['audio/mpeg']
|
||||
unless valid_mimetypes.include?(params[:mimeType])
|
||||
errors[:mimeType] = "invalid. must be one of #{valid_mimetypes.join(',')}"
|
||||
end
|
||||
|
||||
receiver_phone_number = params[:to]
|
||||
|
||||
if errors.present?
|
||||
render json: {
|
||||
errors: errors
|
||||
}, status: :bad_request
|
||||
return
|
||||
end
|
||||
|
||||
caller_phone_number = params[:from].strip
|
||||
|
||||
customer = User.find_by(phone: caller_phone_number)
|
||||
customer ||= User.find_by(mobile: caller_phone_number)
|
||||
unless customer
|
||||
role_ids = Role.signup_role_ids
|
||||
customer = User.create(
|
||||
firstname: '',
|
||||
lastname: '',
|
||||
email: '',
|
||||
password: '',
|
||||
phone: caller_phone_number,
|
||||
active: true,
|
||||
role_ids: role_ids,
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1
|
||||
)
|
||||
end
|
||||
|
||||
# set current user
|
||||
UserInfo.current_user_id = customer.id
|
||||
current_user_set(customer, 'token_auth')
|
||||
|
||||
group = Group.find_by(id: channel.group_id)
|
||||
unless group.present?
|
||||
Rails.logger.error "Voice channel #{channel_id} paired with Group #{channel.group_id}, but group does not exist!"
|
||||
return render json: { error: 'There was an error during voice submission' }, status: 500
|
||||
end
|
||||
|
||||
organization_id = channel.options['organization_id']
|
||||
if organization_id.present?
|
||||
organization = Organization.find_by(id: organization_id)
|
||||
unless organization.present?
|
||||
Rails.logger.error "Voice channel #{channel_id} paired with Organization #{organization_id}, but organization does not exist!"
|
||||
return render json: { error: 'There was an error during voice submission' }, status: 500
|
||||
end
|
||||
unless customer.organization_id.present?
|
||||
customer.organization_id = organization.id
|
||||
customer.save!
|
||||
end
|
||||
end
|
||||
|
||||
call_id = params[:calLSid]
|
||||
duration = params[:duration]
|
||||
start_time = params[:startTime]
|
||||
end_time = params[:endTime]
|
||||
recording_data_base64 = params[:recording]
|
||||
recording_filename = "phone-call-#{start_time}-#{call_id}.mp3"
|
||||
recording_mimetype = params[:mimeType]
|
||||
|
||||
title = "Call from #{caller_phone_number} at #{start_time}"
|
||||
body = %(
|
||||
<ul>
|
||||
<li>Caller: #{caller_phone_number}</li>
|
||||
<li>Service Number: #{receiver_phone_number}</li>
|
||||
<li>Call Duration: #{duration} seconds</li>
|
||||
<li>Start Time: #{start_time}</li>
|
||||
<li>End Time: #{end_time}</li>
|
||||
</ul>
|
||||
<p>See the attached recording.</p>
|
||||
)
|
||||
|
||||
ticket_params = {
|
||||
group_id: group.id,
|
||||
customer_id: customer.id,
|
||||
title: title,
|
||||
preferences: {},
|
||||
note: 'This ticket was created from a recorded voice message.'
|
||||
}
|
||||
|
||||
article_params = {
|
||||
sender: 'Customer',
|
||||
subject: title,
|
||||
body: body,
|
||||
content_type: 'text/html',
|
||||
type: 'note',
|
||||
attachments: [
|
||||
# i don't even...
|
||||
# this is necessary because of what's going on in controllers/concerns/creates_ticket_articles.rb
|
||||
# we need help from the ruby gods
|
||||
{
|
||||
'filename' => recording_filename,
|
||||
:filename => recording_filename,
|
||||
:data => recording_data_base64,
|
||||
'data' => recording_data_base64,
|
||||
'mime-type' => recording_mimetype
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
clean_params = Ticket.param_cleanup(ticket_params, true)
|
||||
ticket = Ticket.new(clean_params)
|
||||
|
||||
ticket.save!
|
||||
ticket.with_lock do
|
||||
article_params[:sender] = 'Customer'
|
||||
article_create(ticket, article_params)
|
||||
end
|
||||
|
||||
result = {
|
||||
ticket: {
|
||||
id: ticket.id,
|
||||
number: ticket.number
|
||||
}
|
||||
}
|
||||
|
||||
render json: result, status: :ok
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,270 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ChannelsCdrWhatsappController < ApplicationController
|
||||
prepend_before_action -> { authentication_check && authorize! }, except: [:webhook]
|
||||
skip_before_action :verify_csrf_token, only: [:webhook]
|
||||
|
||||
include CreatesTicketArticles
|
||||
|
||||
def index
|
||||
assets = {}
|
||||
channel_ids = []
|
||||
Channel.where(area: 'Whatsapp::Number').order(:id).each do |channel|
|
||||
assets = channel.assets(assets)
|
||||
channel_ids.push channel.id
|
||||
end
|
||||
render json: {
|
||||
assets: assets,
|
||||
channel_ids: channel_ids
|
||||
}
|
||||
end
|
||||
|
||||
def add
|
||||
begin
|
||||
errors = {}
|
||||
errors['group_id'] = 'required' if params[:group_id].blank?
|
||||
|
||||
if errors.present?
|
||||
render json: {
|
||||
errors: errors
|
||||
}, status: :bad_request
|
||||
return
|
||||
end
|
||||
channel = Channel.create(
|
||||
area: 'Whatsapp::Number',
|
||||
options: {
|
||||
adapter: 'cdr_whatsapp',
|
||||
phone_number: params[:phone_number],
|
||||
bot_token: params[:bot_token],
|
||||
bot_endpoint: params[:bot_endpoint],
|
||||
token: SecureRandom.urlsafe_base64(48),
|
||||
organization_id: params[:organization_id]
|
||||
},
|
||||
group_id: params[:group_id],
|
||||
active: true
|
||||
)
|
||||
rescue StandardError => e
|
||||
raise Exceptions::UnprocessableEntity, e.message
|
||||
end
|
||||
render json: channel
|
||||
end
|
||||
|
||||
def update
|
||||
errors = {}
|
||||
errors['group_id'] = 'required' if params[:group_id].blank?
|
||||
|
||||
if errors.present?
|
||||
render json: {
|
||||
errors: errors
|
||||
}, status: :bad_request
|
||||
return
|
||||
end
|
||||
channel = Channel.find_by(id: params[:id], area: 'Whatsapp::Number')
|
||||
begin
|
||||
channel.options[:phone_number] = params[:phone_number]
|
||||
channel.options[:bot_token] = params[:bot_token]
|
||||
channel.options[:bot_endpoint] = params[:bot_endpoint]
|
||||
channel.options[:organization_id] = params[:organization_id]
|
||||
channel.group_id = params[:group_id]
|
||||
channel.save!
|
||||
rescue StandardError => e
|
||||
raise Exceptions::UnprocessableEntity, e.message
|
||||
end
|
||||
render json: channel
|
||||
end
|
||||
|
||||
def rotate_token
|
||||
channel = Channel.find_by(id: params[:id], area: 'Whatsapp::Number')
|
||||
channel.options[:token] = SecureRandom.urlsafe_base64(48)
|
||||
channel.save!
|
||||
render json: {}
|
||||
end
|
||||
|
||||
def enable
|
||||
channel = Channel.find_by(id: params[:id], area: 'Whatsapp::Number')
|
||||
channel.active = true
|
||||
channel.save!
|
||||
render json: {}
|
||||
end
|
||||
|
||||
def disable
|
||||
channel = Channel.find_by(id: params[:id], area: 'Whatsapp::Number')
|
||||
channel.active = false
|
||||
channel.save!
|
||||
render json: {}
|
||||
end
|
||||
|
||||
def destroy
|
||||
channel = Channel.find_by(id: params[:id], area: 'Whatsapp::Number')
|
||||
channel.destroy
|
||||
render json: {}
|
||||
end
|
||||
|
||||
def channel_for_token(token)
|
||||
return false unless token
|
||||
|
||||
Channel.where(area: 'Whatsapp::Number').each do |channel|
|
||||
return channel if channel.options[:token] == token
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
def webhook
|
||||
token = params['token']
|
||||
return render json: {}, status: :unauthorized unless token
|
||||
|
||||
channel = channel_for_token(token)
|
||||
return render json: {}, status: :unauthorized if !channel || !channel.active
|
||||
return render json: {}, status: :unauthorized if channel.options[:token] != token
|
||||
|
||||
channel_id = channel.id
|
||||
|
||||
# validate input
|
||||
errors = {}
|
||||
|
||||
%i[to
|
||||
from
|
||||
message_id
|
||||
sent_at].each do |field|
|
||||
errors[field] = 'required' if params[field].blank?
|
||||
end
|
||||
|
||||
if errors.present?
|
||||
render json: {
|
||||
errors: errors
|
||||
}, status: :bad_request
|
||||
return
|
||||
end
|
||||
|
||||
message_id = params[:message_id]
|
||||
|
||||
return if Ticket::Article.exists?(message_id: "cdr_whatsapp.#{message_id}")
|
||||
|
||||
receiver_phone_number = params[:to].strip
|
||||
sender_phone_number = params[:from].strip
|
||||
customer = User.find_by(phone: sender_phone_number)
|
||||
customer ||= User.find_by(mobile: sender_phone_number)
|
||||
unless customer
|
||||
role_ids = Role.signup_role_ids
|
||||
customer = User.create(
|
||||
firstname: '',
|
||||
lastname: '',
|
||||
email: '',
|
||||
password: '',
|
||||
phone: sender_phone_number,
|
||||
note: 'CDR Whatsapp',
|
||||
active: true,
|
||||
role_ids: role_ids,
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1
|
||||
)
|
||||
end
|
||||
|
||||
# set current user
|
||||
UserInfo.current_user_id = customer.id
|
||||
current_user_set(customer, 'token_auth')
|
||||
|
||||
group = Group.find_by(id: channel.group_id)
|
||||
if group.blank?
|
||||
Rails.logger.error "Whatsapp channel #{channel_id} paired with Group #{channel.group_id}, but group does not exist!"
|
||||
return render json: { error: 'There was an error during Whatsapp submission' }, status: :internal_server_error
|
||||
end
|
||||
|
||||
organization_id = channel.options['organization_id']
|
||||
if organization_id.present?
|
||||
organization = Organization.find_by(id: organization_id)
|
||||
if organization.blank?
|
||||
Rails.logger.error "Whatsapp channel #{channel_id} paired with Organization #{organization_id}, but organization does not exist!"
|
||||
return render json: { error: 'There was an error during Whatsapp submission' }, status: :internal_server_error
|
||||
end
|
||||
if customer.organization_id.blank?
|
||||
customer.organization_id = organization.id
|
||||
customer.save!
|
||||
end
|
||||
end
|
||||
|
||||
message = params[:message] ||= 'No text content'
|
||||
sent_at = params[:sent_at]
|
||||
attachment_data_base64 = params[:attachment]
|
||||
attachment_filename = params[:filename]
|
||||
attachment_mimetype = params[:mime_type]
|
||||
title = "Message from #{sender_phone_number} at #{sent_at}"
|
||||
body = message
|
||||
|
||||
# find ticket or create one
|
||||
state_ids = Ticket::State.where(name: %w[closed merged removed]).pluck(:id)
|
||||
ticket = Ticket.where(customer_id: customer.id).where.not(state_id: state_ids).order(:updated_at).first
|
||||
if ticket
|
||||
# check if title need to be updated
|
||||
ticket.title = title if ticket.title == '-'
|
||||
new_state = Ticket::State.find_by(default_create: true)
|
||||
ticket.state = Ticket::State.find_by(default_follow_up: true) if ticket.state_id != new_state.id
|
||||
else
|
||||
ticket = Ticket.new(
|
||||
group_id: channel.group_id,
|
||||
title: title,
|
||||
customer_id: customer.id,
|
||||
preferences: {
|
||||
channel_id: channel.id,
|
||||
cdr_whatsapp: {
|
||||
bot_token: channel.options[:bot_token], # change to bot id
|
||||
chat_id: sender_phone_number
|
||||
}
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
ticket.save!
|
||||
|
||||
article_params = {
|
||||
from: sender_phone_number,
|
||||
to: receiver_phone_number,
|
||||
sender_id: Ticket::Article::Sender.find_by(name: 'Customer').id,
|
||||
subject: title,
|
||||
body: body,
|
||||
content_type: 'text/plain',
|
||||
message_id: "cdr_whatsapp.#{message_id}",
|
||||
ticket_id: ticket.id,
|
||||
internal: false,
|
||||
preferences: {
|
||||
cdr_whatsapp: {
|
||||
timestamp: sent_at,
|
||||
message_id: message_id,
|
||||
from: sender_phone_number
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if attachment_data_base64.present?
|
||||
article_params[:attachments] = [
|
||||
# i don't even...
|
||||
# this is necessary because of what's going on in controllers/concerns/creates_ticket_articles.rb
|
||||
# we need help from the ruby gods
|
||||
{
|
||||
'filename' => attachment_filename,
|
||||
:filename => attachment_filename,
|
||||
:data => attachment_data_base64,
|
||||
'data' => attachment_data_base64,
|
||||
'mime-type' => attachment_mimetype
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
# setting the article type after saving seems to be the only way to get it to stick
|
||||
ticket.with_lock do
|
||||
ta = article_create(ticket, article_params)
|
||||
ta.update!(type_id: Ticket::Article::Type.find_by(name: 'cdr_whatsapp').id)
|
||||
end
|
||||
|
||||
ticket.update!(create_article_type_id: Ticket::Article::Type.find_by(name: 'cdr_whatsapp').id)
|
||||
|
||||
result = {
|
||||
ticket: {
|
||||
id: ticket.id,
|
||||
number: ticket.number
|
||||
}
|
||||
}
|
||||
|
||||
render json: result, status: :ok
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Channel
|
||||
class Driver
|
||||
class CdrSignal
|
||||
def fetchable?(_channel)
|
||||
false
|
||||
end
|
||||
|
||||
def disconnect; end
|
||||
|
||||
#
|
||||
# instance = Channel::Driver::CdrSignal.new
|
||||
# instance.send(
|
||||
# {
|
||||
# adapter: 'cdrsignal',
|
||||
# auth: {
|
||||
# api_key: api_key
|
||||
# },
|
||||
# },
|
||||
# signal_attributes,
|
||||
# notification
|
||||
# )
|
||||
#
|
||||
|
||||
def send(options, article, _notification = false)
|
||||
# return if we run import mode
|
||||
return if Setting.get('import_mode')
|
||||
|
||||
options = check_external_credential(options)
|
||||
|
||||
Rails.logger.debug { 'signal send started' }
|
||||
Rails.logger.debug { options.inspect }
|
||||
@signal = ::CdrSignal.new(options[:bot_endpoint], options[:bot_token])
|
||||
@signal.from_article(article)
|
||||
end
|
||||
|
||||
def self.streamable?
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_external_credential(options)
|
||||
if options[:auth] && options[:auth][:external_credential_id]
|
||||
external_credential = ExternalCredential.find_by(id: options[:auth][:external_credential_id])
|
||||
raise "No such ExternalCredential.find(#{options[:auth][:external_credential_id]})" unless external_credential
|
||||
|
||||
options[:auth][:api_key] = external_credential.credentials['api_key']
|
||||
end
|
||||
options
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Channel
|
||||
class Driver
|
||||
class CdrWhatsapp
|
||||
def fetchable?(_channel)
|
||||
false
|
||||
end
|
||||
|
||||
def disconnect; end
|
||||
|
||||
#
|
||||
# instance = Channel::Driver::CdrWhatsapp.new
|
||||
# instance.send(
|
||||
# {
|
||||
# adapter: 'cdr_whatsapp',
|
||||
# auth: {
|
||||
# api_key: api_key
|
||||
# },
|
||||
# },
|
||||
# whatsapp_attributes,
|
||||
# notification
|
||||
# )
|
||||
#
|
||||
|
||||
def send(options, article, _notification = false)
|
||||
# return if we run import mode
|
||||
return if Setting.get('import_mode')
|
||||
|
||||
options = check_external_credential(options)
|
||||
|
||||
Rails.logger.debug { 'whatsapp send started' }
|
||||
Rails.logger.debug { options.inspect }
|
||||
@whatsapp = ::CdrWhatsapp.new(options[:bot_endpoint], options[:bot_token])
|
||||
@whatsapp.from_article(article)
|
||||
end
|
||||
|
||||
def self.streamable?
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_external_credential(options)
|
||||
if options[:auth] && options[:auth][:external_credential_id]
|
||||
external_credential = ExternalCredential.find_by(id: options[:auth][:external_credential_id])
|
||||
raise "No such ExternalCredential.find(#{options[:auth][:external_credential_id]})" unless external_credential
|
||||
|
||||
options[:auth][:api_key] = external_credential.credentials['api_key']
|
||||
end
|
||||
options
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Observer::Ticket::Article::CommunicateCdrSignal < ActiveRecord::Observer
|
||||
observe 'ticket::_article'
|
||||
|
||||
def after_create(record)
|
||||
# return if we run import mode
|
||||
return true if Setting.get('import_mode')
|
||||
|
||||
# if sender is customer, do not communicate
|
||||
return true unless record.sender_id
|
||||
|
||||
sender = Ticket::Article::Sender.lookup(id: record.sender_id)
|
||||
return true if sender.nil?
|
||||
return true if sender.name == 'Customer'
|
||||
|
||||
# only apply on signal messages
|
||||
return true unless record.type_id
|
||||
|
||||
type = Ticket::Article::Type.lookup(id: record.type_id)
|
||||
return true if type.name !~ /\Acdr_signal/i
|
||||
|
||||
Delayed::Job.enqueue(Observer::Ticket::Article::CommunicateCdrSignal::BackgroundJob.new(record.id))
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Observer
|
||||
module Ticket
|
||||
module Article
|
||||
class CommunicateCdrSignal
|
||||
class BackgroundJob
|
||||
def initialize(id)
|
||||
@article_id = id
|
||||
end
|
||||
|
||||
def perform
|
||||
article = ::Ticket::Article.find(@article_id)
|
||||
|
||||
# set retry count
|
||||
article.preferences['delivery_retry'] ||= 0
|
||||
article.preferences['delivery_retry'] += 1
|
||||
|
||||
ticket = ::Ticket.lookup(id: article.ticket_id)
|
||||
Rails.logger.debug { 'Signal background job' }
|
||||
Rails.logger.debug { ticket.inspect }
|
||||
Rails.logger.debug { article.inspect }
|
||||
unless ticket.preferences
|
||||
log_error(article,
|
||||
"Can't find ticket.preferences for Ticket.find(#{article.ticket_id})")
|
||||
end
|
||||
unless ticket.preferences['cdr_signal']
|
||||
log_error(article,
|
||||
"Can't find ticket.preferences['cdr_signal'] for Ticket.find(#{article.ticket_id})")
|
||||
end
|
||||
unless ticket.preferences['cdr_signal']['chat_id']
|
||||
log_error(article,
|
||||
"Can't find ticket.preferences['cdr_signal']['chat_id'] for Ticket.find(#{article.ticket_id})")
|
||||
end
|
||||
unless ticket.preferences['cdr_signal']['bot_token']
|
||||
log_error(article,
|
||||
"Can't find ticket.preferences['cdr_signal']['bot_token'] for Ticket.find(#{article.ticket_id})")
|
||||
end
|
||||
|
||||
channel = ::CdrSignal.bot_by_bot_token(ticket.preferences['cdr_signal']['bot_token'])
|
||||
Rails.logger.debug { "signal got channel for #{channel.inspect}" }
|
||||
|
||||
channel ||= ::Channel.lookup(id: ticket.preferences['channel_id'])
|
||||
unless channel
|
||||
log_error(article,
|
||||
"No such channel for bot #{ticket.preferences['cdr_signal']['bot_token']} or channel id #{ticket.preferences['channel_id']}")
|
||||
end
|
||||
if channel.options[:bot_token].blank?
|
||||
log_error(article,
|
||||
"Channel.find(#{channel.id}) has no signal api token!")
|
||||
end
|
||||
|
||||
begin
|
||||
result = channel.deliver(
|
||||
to: ticket.preferences[:cdr_signal][:chat_id],
|
||||
body: article.body
|
||||
)
|
||||
rescue StandardError => e
|
||||
log_error(article, e.message)
|
||||
return
|
||||
end
|
||||
|
||||
Rails.logger.debug { "send result: #{result}" }
|
||||
|
||||
if result.nil? || result[:error].present?
|
||||
log_error(article, 'Delivering signal message failed!')
|
||||
return
|
||||
end
|
||||
|
||||
article.to = result['result']['recipient']
|
||||
article.from = result['result']['source']
|
||||
|
||||
message_id = format('%<source>s@%<timestamp>s', source: result['result']['source'],
|
||||
timestamp: result['result']['timestamp'])
|
||||
article.preferences['cdr_signal'] = {
|
||||
timestamp: result['result']['timestamp'],
|
||||
message_id: message_id,
|
||||
from: result['result']['source'],
|
||||
to: result['result']['recipient']
|
||||
}
|
||||
|
||||
# set delivery status
|
||||
article.preferences['delivery_status_message'] = nil
|
||||
article.preferences['delivery_status'] = 'success'
|
||||
article.preferences['delivery_status_date'] = Time.zone.now
|
||||
|
||||
article.message_id = "cdr_signal.#{message_id}"
|
||||
|
||||
article.save!
|
||||
|
||||
Rails.logger.info "Sent signal message to: '#{article.to}' (from #{article.from})"
|
||||
|
||||
article
|
||||
end
|
||||
|
||||
def log_error(local_record, message)
|
||||
local_record.preferences['delivery_status'] = 'fail'
|
||||
local_record.preferences['delivery_status_message'] =
|
||||
message.encode('UTF-8', 'UTF-8', invalid: :replace, replace: '?')
|
||||
local_record.preferences['delivery_status_date'] = Time.zone.now
|
||||
local_record.save
|
||||
Rails.logger.error message
|
||||
|
||||
if local_record.preferences['delivery_retry'] > 3
|
||||
::Ticket::Article.create(
|
||||
ticket_id: local_record.ticket_id,
|
||||
content_type: 'text/plain',
|
||||
body: "Unable to send signal message: #{message}",
|
||||
internal: true,
|
||||
sender: ::Ticket::Article::Sender.find_by(name: 'System'),
|
||||
type: ::Ticket::Article::Type.find_by(name: 'note'),
|
||||
preferences: {
|
||||
delivery_article_id_related: local_record.id,
|
||||
delivery_message: true
|
||||
},
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1
|
||||
)
|
||||
end
|
||||
|
||||
raise message
|
||||
end
|
||||
|
||||
def max_attempts
|
||||
4
|
||||
end
|
||||
|
||||
def reschedule_at(current_time, attempts)
|
||||
return current_time + attempts * 120.seconds if Rails.env.production?
|
||||
|
||||
current_time + 5.seconds
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Observer::Ticket::Article::CommunicateCdrWhatsapp < ActiveRecord::Observer
|
||||
observe 'ticket::_article'
|
||||
|
||||
def after_create(record)
|
||||
# return if we run import mode
|
||||
return true if Setting.get('import_mode')
|
||||
|
||||
# if sender is customer, do not communicate
|
||||
return true unless record.sender_id
|
||||
|
||||
sender = Ticket::Article::Sender.lookup(id: record.sender_id)
|
||||
return true if sender.nil?
|
||||
return true if sender.name == 'Customer'
|
||||
|
||||
# only apply on whatsapp messages
|
||||
return true unless record.type_id
|
||||
|
||||
type = Ticket::Article::Type.lookup(id: record.type_id)
|
||||
return true if type.name !~ /\Acdr_whatsapp/i
|
||||
|
||||
Delayed::Job.enqueue(Observer::Ticket::Article::CommunicateCdrWhatsapp::BackgroundJob.new(record.id))
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Observer
|
||||
module Ticket
|
||||
module Article
|
||||
class CommunicateCdrWhatsapp
|
||||
class BackgroundJob
|
||||
def initialize(id)
|
||||
@article_id = id
|
||||
end
|
||||
|
||||
def perform
|
||||
article = ::Ticket::Article.find(@article_id)
|
||||
|
||||
# set retry count
|
||||
article.preferences['delivery_retry'] ||= 0
|
||||
article.preferences['delivery_retry'] += 1
|
||||
|
||||
ticket = ::Ticket.lookup(id: article.ticket_id)
|
||||
Rails.logger.debug { 'Whatsapp background job' }
|
||||
Rails.logger.debug { ticket.inspect }
|
||||
Rails.logger.debug { article.inspect }
|
||||
unless ticket.preferences
|
||||
log_error(article,
|
||||
"Can't find ticket.preferences for Ticket.find(#{article.ticket_id})")
|
||||
end
|
||||
unless ticket.preferences['cdr_whatsapp']
|
||||
log_error(article,
|
||||
"Can't find ticket.preferences['cdr_whatsapp'] for Ticket.find(#{article.ticket_id})")
|
||||
end
|
||||
unless ticket.preferences['cdr_whatsapp']['chat_id']
|
||||
log_error(article,
|
||||
"Can't find ticket.preferences['cdr_whatsapp']['chat_id'] for Ticket.find(#{article.ticket_id})")
|
||||
end
|
||||
unless ticket.preferences['cdr_whatsapp']['bot_token']
|
||||
log_error(article,
|
||||
"Can't find ticket.preferences['cdr_whatsapp']['bot_token'] for Ticket.find(#{article.ticket_id})")
|
||||
end
|
||||
|
||||
channel = ::CdrWhatsapp.bot_by_bot_token(ticket.preferences['cdr_whatsapp']['bot_token'])
|
||||
Rails.logger.debug { "whatsapp got channel for #{channel.inspect}" }
|
||||
|
||||
channel ||= ::Channel.lookup(id: ticket.preferences['channel_id'])
|
||||
unless channel
|
||||
log_error(article,
|
||||
"No such channel for bot #{ticket.preferences['cdr_whatsapp']['bot_token']} or channel id #{ticket.preferences['channel_id']}")
|
||||
end
|
||||
if channel.options[:bot_token].blank?
|
||||
log_error(article,
|
||||
"Channel.find(#{channel.id}) has no whatsapp api token!")
|
||||
end
|
||||
|
||||
begin
|
||||
result = channel.deliver(
|
||||
to: ticket.preferences[:cdr_whatsapp][:chat_id],
|
||||
body: article.body
|
||||
)
|
||||
rescue StandardError => e
|
||||
log_error(article, e.message)
|
||||
return
|
||||
end
|
||||
|
||||
Rails.logger.debug { "send result: #{result}" }
|
||||
|
||||
if result.nil? || result[:error].present?
|
||||
log_error(article, 'Delivering whatsapp message failed!')
|
||||
return
|
||||
end
|
||||
|
||||
article.to = result['result']['recipient']
|
||||
article.from = result['result']['source']
|
||||
|
||||
message_id = format('%<source>s@%<timestamp>s', source: result['result']['source'],
|
||||
timestamp: result['result']['timestamp'])
|
||||
article.preferences['cdr_whatsapp'] = {
|
||||
timestamp: result['result']['timestamp'],
|
||||
message_id: message_id,
|
||||
from: result['result']['source'],
|
||||
to: result['result']['recipient']
|
||||
}
|
||||
|
||||
# set delivery status
|
||||
article.preferences['delivery_status_message'] = nil
|
||||
article.preferences['delivery_status'] = 'success'
|
||||
article.preferences['delivery_status_date'] = Time.zone.now
|
||||
|
||||
article.message_id = "cdr_whatsapp.#{message_id}"
|
||||
|
||||
article.save!
|
||||
|
||||
Rails.logger.info "Sent whatsapp message to: '#{article.to}' (from #{article.from})"
|
||||
|
||||
article
|
||||
end
|
||||
|
||||
def log_error(local_record, message)
|
||||
local_record.preferences['delivery_status'] = 'fail'
|
||||
local_record.preferences['delivery_status_message'] =
|
||||
message.encode('UTF-8', 'UTF-8', invalid: :replace, replace: '?')
|
||||
local_record.preferences['delivery_status_date'] = Time.zone.now
|
||||
local_record.save
|
||||
Rails.logger.error message
|
||||
|
||||
if local_record.preferences['delivery_retry'] > 3
|
||||
::Ticket::Article.create(
|
||||
ticket_id: local_record.ticket_id,
|
||||
content_type: 'text/plain',
|
||||
body: "Unable to send whatsapp message: #{message}",
|
||||
internal: true,
|
||||
sender: ::Ticket::Article::Sender.find_by(name: 'System'),
|
||||
type: ::Ticket::Article::Type.find_by(name: 'note'),
|
||||
preferences: {
|
||||
delivery_article_id_related: local_record.id,
|
||||
delivery_message: true
|
||||
},
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1
|
||||
)
|
||||
end
|
||||
|
||||
raise message
|
||||
end
|
||||
|
||||
def max_attempts
|
||||
4
|
||||
end
|
||||
|
||||
def reschedule_at(current_time, attempts)
|
||||
return current_time + attempts * 120.seconds if Rails.env.production?
|
||||
|
||||
current_time + 5.seconds
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Controllers
|
||||
class ChannelsCdrSignalControllerPolicy < Controllers::ApplicationControllerPolicy
|
||||
default_permit!('admin.channel_cdr_signal')
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Controllers
|
||||
class ChannelsCdrVoiceControllerPolicy < Controllers::ApplicationControllerPolicy
|
||||
default_permit!('admin.channel_cdr_voice')
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Controllers
|
||||
class ChannelsCdrWhatsappControllerPolicy < Controllers::ApplicationControllerPolicy
|
||||
default_permit!('admin.channel_cdr_whatsapp')
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue