Next release WIP #

This commit is contained in:
Darren Clarke 2025-10-27 21:02:19 +01:00
parent 7d7944fa90
commit 20078ccacc
10 changed files with 219 additions and 94 deletions

View file

@ -47,8 +47,14 @@ class CdrSignalReply
# Check CDR Link allowed channels setting
allowedChannels = ui.Config.get('cdr_link_allowed_channels')
if allowedChannels && allowedChannels.trim()
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

View file

@ -0,0 +1,17 @@
# frozen_string_literal: true
class CdrTicketArticleTypesController < ApplicationController
prepend_before_action -> { authentication_check && authorize! }
def index
types = Ticket::Article::Type.all.map do |type|
{
id: type.id,
name: type.name,
communication: type.communication
}
end
render json: types
end
end

View file

@ -0,0 +1,9 @@
# frozen_string_literal: true
module Controllers
class CdrTicketArticleTypesControllerPolicy < Controllers::ApplicationControllerPolicy
def index?
true
end
end
end

View file

@ -0,0 +1,5 @@
Zammad::Application.routes.draw do
api_path = Rails.configuration.api_path
match api_path + '/ticket_article_types', to: 'cdr_ticket_article_types#index', via: :get
end

View file

@ -0,0 +1,41 @@
# frozen_string_literal: true
class AddCdrLinkConfig < ActiveRecord::Migration[5.2]
def self.up
Setting.create_if_not_exists(
title: 'CDR Link',
name: 'cdr_link_config',
area: 'Integration::CDRLink',
description: 'Defines the CDR Link integration config.',
options: {},
state: { items: [] },
frontend: false,
preferences: {
prio: 2,
permission: ['admin.integration'],
}
)
# Update the existing allowed_channels setting to use admin.integration permission
setting = Setting.find_by(name: 'cdr_link_allowed_channels')
if setting
setting.preferences = {
permission: ['admin.integration'],
}
setting.save!
end
end
def self.down
Setting.find_by(name: 'cdr_link_config')&.destroy
# Restore original permission if rolling back
setting = Setting.find_by(name: 'cdr_link_allowed_channels')
if setting
setting.preferences = {
permission: ['admin'],
}
setting.save!
end
end
end