Add signal and whatsapp plugins

This commit is contained in:
Darren Clarke 2025-09-05 11:19:20 +02:00
parent d2a3c71bcd
commit 38de035571
2 changed files with 145 additions and 0 deletions

View file

@ -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

View file

@ -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;