| 1 | import type { WebhookBody, WebhookPing } from '../webhooks.js'; |
| 2 | import { discord } |
| 3 | import { googleChat } |
| 4 | import { messageOf, type |
| 5 | import { slack } |
| 6 | import { teams } |
| 7 | |
| 8 | /** Who a chat message is from, where the service lets a webhook say. */ |
| 9 | export type WebhookSender |
| 10 | |
| 11 | /** A chat service whose incoming webhooks want their own JSON instead of Ghost's. */ |
| 12 | export type WebhookFormat |
| 13 | matches: (url |
| 14 | render: (message |
| 15 | }; |
| 16 | |
| 17 | /** To support another service, add a file beside these and list it here; to stop, remove it. An endpoint no format matches gets Ghost's own JSON. */ |
| 18 | const formats: WebhookFormat |
| 19 | |
| 20 | /** The exact bytes `url` receives for `body`. */ |
| 21 | export function renderWebhookBody( |
| 22 | url: string, |
| 23 | body: WebhookBody |
| 24 | sender: WebhookSender |
| 25 | ) { |
| 26 | const parsed = |
| 27 | const format = |
| 28 | parsed && formats. |
| 29 | return JSON.stringify |
| 30 | } |