Channel filter updates
This commit is contained in:
parent
20078ccacc
commit
e3133e305c
4 changed files with 49 additions and 17 deletions
|
|
@ -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) ->
|
||||
return articleTypes if !ui.permissionCheck('ticket.agent')
|
||||
|
||||
# Check CDR Link allowed channels setting
|
||||
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
|
||||
|
||||
# Check if this ticket was created via Signal
|
||||
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'
|
||||
# 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 {
|
||||
name: 'cdr_signal'
|
||||
icon: 'cdr-signal'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue