diff --git a/src/lib/server/notifications.ts b/src/lib/server/notifications.ts index 734b7d5..f1e3528 100644 --- a/src/lib/server/notifications.ts +++ b/src/lib/server/notifications.ts @@ -126,6 +126,8 @@ async function sendToAppriseUrl(url: string, payload: NotificationPayload): Prom case 'json': case 'jsons': return await sendGenericWebhook(url, payload); + case 'workflows': + return await sendWorkflows(url, payload); default: console.warn(`[Notifications] Unsupported Apprise protocol: ${protocol}`); return false; @@ -318,6 +320,49 @@ async function sendGenericWebhook(appriseUrl: string, payload: NotificationPaylo return response.ok; } +// Microsoft Power Automate Workflows, for e.g. Microsoft Teams +async function sendWorkflows(appriseUrl: string, payload: NotificationPayload): Promise { + // workflows://hostname/workflow/signature + const match = appriseUrl.match(/^workflows?:\/\/([^/]+)\/(.+)\/(.+)/); + if (!match) return false; + + const [, hostname, workflow, signature] = match; + const url = `https://${hostname}/powerautomate/automations/direct/workflows/${workflow}/triggers/manual/paths/invoke?api-version=1&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=${signature}`; + + const response = await fetch(url, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + type: 'message', + attachments: [ + { + contentType: 'application/vnd.microsoft.card.adaptive', + content: { + $schema: 'https://adaptivecards.io/schemas/adaptive-card.json', + type: 'AdaptiveCard', + version: '1.2', + body: [ + { + type: 'TextBlock', + style: 'heading', + wrap: true, + text: payload.title + }, + { + type: 'TextBlock', + style: 'default', + wrap: true, + text: payload.message + } + ] + } + } + ] + }) + }); + + return response.ok; +} // Send notification to all enabled channels export async function sendNotification(payload: NotificationPayload): Promise<{ success: boolean; results: { name: string; success: boolean }[] }> { diff --git a/src/routes/settings/notifications/NotificationModal.svelte b/src/routes/settings/notifications/NotificationModal.svelte index ea09408..5f31b8f 100644 --- a/src/routes/settings/notifications/NotificationModal.svelte +++ b/src/routes/settings/notifications/NotificationModal.svelte @@ -417,11 +417,12 @@ slack://token_a/token_b/token_c tgram://bot_token/chat_id ntfy://my-topic pushover://user_key/api_token +workflows://hostname/workflow/signature jsons://hostname/webhook/path" class="flex min-h-[220px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring" >

- Supports Gotify (gotify:// or gotifys:// for HTTPS), Discord, Slack, Telegram, ntfy, Pushover, and generic JSON webhooks. + Supports Gotify (gotify:// or gotifys:// for HTTPS), Discord, Slack, Telegram, ntfy, Pushover, Workflows (for e.g. Microsoft Teams), and generic JSON webhooks.