Channel filter updates
This commit is contained in:
parent
20078ccacc
commit
e3133e305c
4 changed files with 49 additions and 17 deletions
|
|
@ -1 +1 @@
|
||||||
FROM bbernhard/signal-cli-rest-api:0.176-dev
|
FROM bbernhard/signal-cli-rest-api:0.95
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
class CdrLinkChannelFilter
|
||||||
|
# Required stub - we don't add any actions, just pass through
|
||||||
|
@action: (actions, ticket, article, ui) ->
|
||||||
|
actions
|
||||||
|
|
||||||
|
@articleTypes: (articleTypes, ticket, ui) ->
|
||||||
|
return articleTypes if !ui.permissionCheck('ticket.agent')
|
||||||
|
|
||||||
|
# Check CDR Link allowed channels setting
|
||||||
|
allowedChannels = ui.Config.get('cdr_link_allowed_channels')
|
||||||
|
|
||||||
|
# If no whitelist is configured, allow all types
|
||||||
|
if !allowedChannels || !allowedChannels.trim()
|
||||||
|
return articleTypes
|
||||||
|
|
||||||
|
# Parse the comma-separated whitelist
|
||||||
|
whitelist = (channel.trim() for channel in allowedChannels.split(','))
|
||||||
|
|
||||||
|
# Filter article types to only those in the whitelist
|
||||||
|
# Always keep 'note' for internal notes regardless of whitelist
|
||||||
|
filteredTypes = articleTypes.filter (type) ->
|
||||||
|
type.name is 'note' or type.name in whitelist
|
||||||
|
|
||||||
|
# Add email if it's in the whitelist but not in the array
|
||||||
|
# (Email is only added by Zammad core for email tickets, not Signal tickets)
|
||||||
|
if 'email' in whitelist
|
||||||
|
hasEmail = filteredTypes.some (type) -> type.name is 'email'
|
||||||
|
if !hasEmail
|
||||||
|
# Add email with all the standard email attributes
|
||||||
|
filteredTypes.push {
|
||||||
|
name: 'email'
|
||||||
|
icon: 'email'
|
||||||
|
attributes: ['to', 'cc', 'subject']
|
||||||
|
internal: false
|
||||||
|
features: ['attachment']
|
||||||
|
}
|
||||||
|
|
||||||
|
filteredTypes
|
||||||
|
|
||||||
|
App.Config.set('900-CdrLinkChannelFilter', CdrLinkChannelFilter, 'TicketZoomArticleAction')
|
||||||
|
|
@ -45,24 +45,16 @@ class CdrSignalReply
|
||||||
@articleTypes: (articleTypes, ticket, ui) ->
|
@articleTypes: (articleTypes, ticket, ui) ->
|
||||||
return articleTypes if !ui.permissionCheck('ticket.agent')
|
return articleTypes if !ui.permissionCheck('ticket.agent')
|
||||||
|
|
||||||
# Check CDR Link allowed channels setting
|
# Check if this ticket was created via Signal
|
||||||
allowedChannels = ui.Config.get('cdr_link_allowed_channels')
|
|
||||||
hasWhitelist = allowedChannels && allowedChannels.trim()
|
|
||||||
|
|
||||||
if hasWhitelist
|
|
||||||
whitelist = (channel.trim() for channel in allowedChannels.split(','))
|
|
||||||
# Filter articleTypes to only those in the whitelist (keep 'note' for internal notes)
|
|
||||||
articleTypes = articleTypes.filter (type) ->
|
|
||||||
type.name is 'note' or type.name in whitelist
|
|
||||||
|
|
||||||
# Return early if 'cdr_signal' or 'signal message' not in whitelist
|
|
||||||
return articleTypes if 'cdr_signal' not in whitelist && 'signal message' not in whitelist
|
|
||||||
|
|
||||||
return articleTypes if !ticket || !ticket.create_article_type_id
|
return articleTypes if !ticket || !ticket.create_article_type_id
|
||||||
|
|
||||||
articleTypeCreate = App.TicketArticleType.find(ticket.create_article_type_id).name
|
articleTypeCreate = App.TicketArticleType.find(ticket.create_article_type_id).name
|
||||||
|
|
||||||
return articleTypes if articleTypeCreate isnt 'cdr_signal'
|
# Only add cdr_signal type if ticket was created via Signal
|
||||||
|
if articleTypeCreate isnt 'cdr_signal'
|
||||||
|
return articleTypes
|
||||||
|
|
||||||
|
# Add the cdr_signal article type for Signal replies
|
||||||
articleTypes.push {
|
articleTypes.push {
|
||||||
name: 'cdr_signal'
|
name: 'cdr_signal'
|
||||||
icon: 'cdr-signal'
|
icon: 'cdr-signal'
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,5 @@ require '/opt/zammad/config/application'
|
||||||
|
|
||||||
Rails.application.initialize!
|
Rails.application.initialize!
|
||||||
|
|
||||||
Setting.set('cdr_link_allowed_channels', 'note,signal message')
|
Setting.set('cdr_link_allowed_channels', 'note,cdr_signal,email')
|
||||||
puts "Setting 'cdr_link_allowed_channels' has been set to: 'note,signal message'"
|
puts "Setting 'cdr_link_allowed_channels' has been set to: 'note,cdr_signal,email'"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue