Files
buzz-sheet/lib/commission/message-event.ts
T
gunshiz 3473b55768
CI / Verify (push) Successful in 1m48s
CI / Build immutable images and deploy (push) Successful in 2m47s
feat(commission) : add push notifications and unread ticket titles
2026-10-02 11:51:05 +07:00

16 lines
730 B
TypeScript

export type CommissionMessageEvent = {
messageId: string; ticketId: string; ticketTitle: string; authorId: string;
authorName: string; text: string | null;
};
export function parseCommissionMessageEvent(value: string): CommissionMessageEvent | null {
if (!value.startsWith("message:")) return null;
try {
const message = JSON.parse(value.slice(8)) as CommissionMessageEvent;
return typeof message.messageId === "string" && typeof message.ticketId === "string" &&
typeof message.ticketTitle === "string" && typeof message.authorId === "string" &&
typeof message.authorName === "string" &&
(typeof message.text === "string" || message.text === null) ? message : null;
} catch { return null; }
}