From 61e78a85d8405695a71ebb535c8b39ff3e047946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Pluta?= Date: Wed, 4 Jun 2025 22:13:43 +0200 Subject: [PATCH] Add support for overriding completion buttons --- src/backend/ntfy.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/backend/ntfy.ts b/src/backend/ntfy.ts index 687079c..33f1f3a 100644 --- a/src/backend/ntfy.ts +++ b/src/backend/ntfy.ts @@ -13,6 +13,12 @@ type NtfyConfig = { map?: string; combineMap?: string; topic?: string; + completion?: { + completeButton?: string; + completeButton1?: string; + completeButton2?: string; + completeButton3?: string; + } } & BackendSettings; type NtfyDTO = { @@ -41,7 +47,7 @@ export class NtfySH extends Backend { const dto = mapper(task); const actions = task && profileConfig.completion?.enable && config.server?.baseUrl && !task.recurrenceRule - ? [buildCompleteAction(task, profileConfig.name, config.server.baseUrl, "✅")] + ? [buildCompleteAction(task, profileConfig.name, config.server.baseUrl, backendConfig?.completion?.completeButton ?? "✅")] : []; this.#doNotify(backendConfig, dto, actions); @@ -49,6 +55,11 @@ export class NtfySH extends Backend { protected async notifyCombined(config: Config, profileConfig: ProfileConfig, backendConfig: NtfyConfig, tasks: Task[]): Promise { const chunks = chunkArray(tasks, 3); + const completionLabels = [ + backendConfig?.completion?.completeButton1 ?? "✅1️⃣", + backendConfig?.completion?.completeButton2 ?? "✅2️⃣", + backendConfig?.completion?.completeButton3 ?? "✅3️⃣" + ]; const context = { mapPriority, @@ -63,7 +74,7 @@ export class NtfySH extends Backend { const dto = mapper(chunk); const actions = profileConfig.completion?.enable && config.server?.baseUrl - ? chunk.map((t, i) => buildCompleteAction(t, profileConfig.name, config.server!.baseUrl!, ["✅1️⃣", "✅2️⃣", "✅3️⃣"][i] ?? "✅")) + ? chunk.map((t, i) => buildCompleteAction(t, profileConfig.name, config.server!.baseUrl!, completionLabels[i] ?? "✅")) : []; await this.#doNotify(backendConfig, dto, actions); @@ -101,7 +112,7 @@ function buildCompleteAction(task: Task, profile: string, baseUrl: string, label return { action: "http", - label: "✅", + label, url: `${baseUrl}/complete`, method: "POST", headers: {