From 38de035571477445525946bee13ae6f8f7885402 Mon Sep 17 00:00:00 2001 From: Darren Clarke Date: Fri, 5 Sep 2025 11:19:20 +0200 Subject: [PATCH] Add signal and whatsapp plugins --- .../action/plugins/cdr_signal.ts | 69 +++++++++++++++++ .../action/plugins/cdr_whatsapp.ts | 76 +++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 packages/zammad-addon-bridge/src/app/frontend/shared/entities/ticket-article/action/plugins/cdr_signal.ts create mode 100644 packages/zammad-addon-bridge/src/app/frontend/shared/entities/ticket-article/action/plugins/cdr_whatsapp.ts diff --git a/packages/zammad-addon-bridge/src/app/frontend/shared/entities/ticket-article/action/plugins/cdr_signal.ts b/packages/zammad-addon-bridge/src/app/frontend/shared/entities/ticket-article/action/plugins/cdr_signal.ts new file mode 100644 index 0000000..f72a2ed --- /dev/null +++ b/packages/zammad-addon-bridge/src/app/frontend/shared/entities/ticket-article/action/plugins/cdr_signal.ts @@ -0,0 +1,69 @@ +import { EnumTicketArticleSenderName } from '#shared/graphql/types.ts' + +import type { TicketArticleAction, TicketArticleActionPlugin, TicketArticleType } from './types.ts' + +const actionPlugin: TicketArticleActionPlugin = { + order: 350, + + addActions(ticket, article) { + const sender = article.sender?.name + const type = article.type?.name + + if (sender !== EnumTicketArticleSenderName.Customer || type !== 'signal message') + return [] + + const action: TicketArticleAction = { + apps: ['mobile', 'desktop'], + label: __('Reply'), + name: 'signal message', + icon: 'cdr-signal', + view: { + agent: ['change'], + }, + perform(ticket, article, { openReplyForm }) { + const articleData = { + articleType: type, + inReplyTo: article.messageId, + } + + openReplyForm(articleData) + }, + } + return [action] + }, + + addTypes(ticket) { + const descriptionType = ticket.createArticleType?.name + + if (descriptionType !== 'signal message') return [] + + const type: TicketArticleType = { + apps: ['mobile', 'desktop'], + value: 'signal message', + label: __('Signal'), + buttonLabel: __('Add Signal message'), + icon: 'cdr-signal', + view: { + agent: ['change'], + }, + internal: false, + contentType: 'text/plain', + fields: { + body: { + required: true, + validation: 'length:1,10000', + }, + attachments: {}, + }, + editorMeta: { + footer: { + maxlength: 10000, + warningLength: 5000, + }, + }, + } + return [type] + }, +} + +export default actionPlugin diff --git a/packages/zammad-addon-bridge/src/app/frontend/shared/entities/ticket-article/action/plugins/cdr_whatsapp.ts b/packages/zammad-addon-bridge/src/app/frontend/shared/entities/ticket-article/action/plugins/cdr_whatsapp.ts new file mode 100644 index 0000000..2866982 --- /dev/null +++ b/packages/zammad-addon-bridge/src/app/frontend/shared/entities/ticket-article/action/plugins/cdr_whatsapp.ts @@ -0,0 +1,76 @@ +import { EnumTicketArticleSenderName } from "#shared/graphql/types.ts"; + +import type { + TicketArticleAction, + TicketArticleActionPlugin, + TicketArticleType, +} from "./types.ts"; + +const actionPlugin: TicketArticleActionPlugin = { + order: 360, + + addActions(ticket, article) { + const sender = article.sender?.name; + const type = article.type?.name; + + if ( + sender !== EnumTicketArticleSenderName.Customer || + type !== "whatsapp message" + ) + return []; + + const action: TicketArticleAction = { + apps: ["mobile", "desktop"], + label: __("Reply"), + name: "whatsapp message", + icon: "cdr-whatsapp", + view: { + agent: ["change"], + }, + perform(ticket, article, { openReplyForm }) { + const articleData = { + articleType: type, + inReplyTo: article.messageId, + }; + + openReplyForm(articleData); + }, + }; + return [action]; + }, + + addTypes(ticket) { + const descriptionType = ticket.createArticleType?.name; + + if (descriptionType !== "whatsapp message") return []; + + const type: TicketArticleType = { + apps: ["mobile", "desktop"], + value: "whatsapp message", + label: __("WhatsApp"), + buttonLabel: __("Add WhatsApp message"), + icon: "cdr-whatsapp", + view: { + agent: ["change"], + }, + internal: false, + contentType: "text/plain", + fields: { + body: { + required: true, + validation: "length:1,4096", + }, + attachments: {}, + }, + editorMeta: { + footer: { + maxlength: 4096, + warningLength: 3000, + }, + }, + }; + return [type]; + }, +}; + +export default actionPlugin;