Add support for overriding completion buttons
This commit is contained in:
@@ -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<NtfyConfig> {
|
||||
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<NtfyConfig> {
|
||||
|
||||
protected async notifyCombined(config: Config, profileConfig: ProfileConfig, backendConfig: NtfyConfig, tasks: Task[]): Promise<void> {
|
||||
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<NtfyConfig> {
|
||||
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: {
|
||||
|
||||
Reference in New Issue
Block a user