Add support for overriding completion buttons
This commit is contained in:
@@ -13,6 +13,12 @@ type NtfyConfig = {
|
|||||||
map?: string;
|
map?: string;
|
||||||
combineMap?: string;
|
combineMap?: string;
|
||||||
topic?: string;
|
topic?: string;
|
||||||
|
completion?: {
|
||||||
|
completeButton?: string;
|
||||||
|
completeButton1?: string;
|
||||||
|
completeButton2?: string;
|
||||||
|
completeButton3?: string;
|
||||||
|
}
|
||||||
} & BackendSettings;
|
} & BackendSettings;
|
||||||
|
|
||||||
type NtfyDTO = {
|
type NtfyDTO = {
|
||||||
@@ -41,7 +47,7 @@ export class NtfySH extends Backend<NtfyConfig> {
|
|||||||
const dto = mapper(task);
|
const dto = mapper(task);
|
||||||
|
|
||||||
const actions = task && profileConfig.completion?.enable && config.server?.baseUrl && !task.recurrenceRule
|
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);
|
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> {
|
protected async notifyCombined(config: Config, profileConfig: ProfileConfig, backendConfig: NtfyConfig, tasks: Task[]): Promise<void> {
|
||||||
const chunks = chunkArray(tasks, 3);
|
const chunks = chunkArray(tasks, 3);
|
||||||
|
const completionLabels = [
|
||||||
|
backendConfig?.completion?.completeButton1 ?? "✅1️⃣",
|
||||||
|
backendConfig?.completion?.completeButton2 ?? "✅2️⃣",
|
||||||
|
backendConfig?.completion?.completeButton3 ?? "✅3️⃣"
|
||||||
|
];
|
||||||
|
|
||||||
const context = {
|
const context = {
|
||||||
mapPriority,
|
mapPriority,
|
||||||
@@ -63,7 +74,7 @@ export class NtfySH extends Backend<NtfyConfig> {
|
|||||||
const dto = mapper(chunk);
|
const dto = mapper(chunk);
|
||||||
|
|
||||||
const actions = profileConfig.completion?.enable && config.server?.baseUrl
|
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);
|
await this.#doNotify(backendConfig, dto, actions);
|
||||||
@@ -101,7 +112,7 @@ function buildCompleteAction(task: Task, profile: string, baseUrl: string, label
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
action: "http",
|
action: "http",
|
||||||
label: "✅",
|
label,
|
||||||
url: `${baseUrl}/complete`,
|
url: `${baseUrl}/complete`,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Reference in New Issue
Block a user