Add preference for signal notifications to bot setup screen

This commit is contained in:
Darren Clarke 2026-01-28 14:46:34 +01:00
parent 38efae02d4
commit d93797172a
10 changed files with 1232 additions and 1214 deletions

View file

@ -42,10 +42,11 @@ RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
apt-get install -y --no-install-recommends \
dumb-init
RUN mkdir -p ${APP_DIR}
RUN chown -R node ${APP_DIR}/
RUN mkdir -p ${APP_DIR} /pnpm
RUN chown -R node ${APP_DIR}/ /pnpm
USER node
RUN corepack prepare pnpm@9.15.4 --activate
WORKDIR ${APP_DIR}
COPY --from=installer ${APP_DIR} ./
USER root

View file

@ -7,6 +7,8 @@ class ChannelCdrSignal extends App.ControllerSubContent
'click .js-disable': 'disable'
'click .js-enable': 'enable'
'click .js-rotate-token': 'rotateToken'
'click .js-set-notification': 'setNotification'
'click .js-unset-notification': 'unsetNotification'
constructor: ->
super
@ -41,6 +43,8 @@ class ChannelCdrSignal extends App.ControllerSubContent
channels.push channel
@html App.view('cdr_signal/index')(
channels: channels
notificationEnabled: data.notification_enabled
notificationChannelId: data.notification_channel_id
)
new: (e) =>
@ -124,6 +128,31 @@ class ChannelCdrSignal extends App.ControllerSubContent
@load()
)
setNotification: (e) =>
e.preventDefault()
id = $(e.target).closest('.action').data('id')
@ajax(
id: 'cdr_signal_set_notification'
type: 'POST'
url: "#{@apiPath}/channels_cdr_signal_set_notification"
data: JSON.stringify(id: id)
processData: true
success: =>
@load()
)
unsetNotification: (e) =>
e.preventDefault()
@ajax(
id: 'cdr_signal_unset_notification'
type: 'POST'
url: "#{@apiPath}/channels_cdr_signal_unset_notification"
data: JSON.stringify({})
processData: true
success: =>
@load()
)
class FormAdd extends App.ControllerModal
head: 'Add Web Form'
shown: true

View file

@ -20,6 +20,9 @@
<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>
<% if @notificationEnabled and @notificationChannelId is channel.id: %>
<span class="label label--success" style="margin-left: 10px;"><%- @T('Agent Notifications') %></span>
<% end %>
</div>
<div class="action-flow action-flow--row">
<div class="action-block">
@ -42,6 +45,11 @@
<% else: %>
<div class="btn btn--secondary js-enable"><%- @T('Enable') %></div>
<% end %>
<% if @notificationEnabled and @notificationChannelId is channel.id: %>
<div class="btn btn--secondary js-unset-notification"><%- @T('Disable Agent Notifications') %></div>
<% else if channel.active is true: %>
<div class="btn btn--success btn--secondary js-set-notification"><%- @T('Use for Agent Notifications') %></div>
<% end %>
<div class="btn js-edit"><%- @T('Edit') %></div>
</div>
</div>

View file

@ -15,10 +15,34 @@ class ChannelsCdrSignalController < ApplicationController
end
render json: {
assets: assets,
channel_ids: channel_ids
channel_ids: channel_ids,
notification_enabled: Setting.get('signal_notification_enabled') == true,
notification_channel_id: Setting.get('signal_notification_channel_id')
}
end
def set_notification_channel
channel_id = params[:id].to_i
channel = Channel.find_by(id: channel_id, area: 'Signal::Number')
unless channel
render json: { error: 'Channel not found' }, status: :not_found
return
end
Setting.set('signal_notification_channel_id', channel_id)
Setting.set('signal_notification_enabled', true)
render json: { success: true, notification_channel_id: channel_id }
end
def unset_notification_channel
Setting.set('signal_notification_enabled', false)
Setting.set('signal_notification_channel_id', nil)
render json: { success: true }
end
def add
begin
errors = {}

View file

@ -45,7 +45,7 @@ class SignalNotificationJob < ApplicationJob
channel_id = Setting.get('signal_notification_channel_id')
return unless channel_id
Channel.find_by(id: channel_id, area: 'Signal::Account', active: true)
Channel.find_by(id: channel_id, area: 'Signal::Number', active: true)
end
def add_history(ticket, user, type)

View file

@ -63,7 +63,7 @@ class Transaction::SignalNotification
channel_id = Setting.get('signal_notification_channel_id')
return unless channel_id
Channel.find_by(id: channel_id, area: 'Signal::Account', active: true)
Channel.find_by(id: channel_id, area: 'Signal::Number', active: true)
end
end

View file

@ -12,4 +12,6 @@ Zammad::Application.routes.draw do
match "#{api_path}/channels_cdr_signal_enable", to: 'channels_cdr_signal#enable', via: :post
match "#{api_path}/channels_cdr_signal", to: 'channels_cdr_signal#destroy', via: :delete
match "#{api_path}/channels_cdr_signal_rotate_token", to: 'channels_cdr_signal#rotate_token', via: :post
match "#{api_path}/channels_cdr_signal_set_notification", to: 'channels_cdr_signal#set_notification_channel', via: :post
match "#{api_path}/channels_cdr_signal_unset_notification", to: 'channels_cdr_signal#unset_notification_channel', via: :post
end

View file

@ -0,0 +1,9 @@
{
"$schema": "https://turbo.build/schema.json",
"extends": ["//"],
"tasks": {
"build": {
"outputs": ["../../docker/zammad/addons/zammad-addon-bridge-v*.zpm"]
}
}
}

View file

@ -0,0 +1,9 @@
{
"$schema": "https://turbo.build/schema.json",
"extends": ["//"],
"tasks": {
"build": {
"outputs": ["../../docker/zammad/addons/zammad-addon-hardening-v*.zpm"]
}
}
}

2354
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff