From 509462e1182f0fb54c5cdb12fcecea454307ea8d Mon Sep 17 00:00:00 2001 From: Collin Duncan <3679940+cgduncan7@users.noreply.github.com> Date: Thu, 19 Sep 2024 13:05:20 +0200 Subject: [PATCH] Removing some ntfy logs and adding more error handling for 4xx+ errors --- src/ntfy/client.ts | 9 ++++----- src/ntfy/provider.ts | 1 - src/ntfy/types.ts | 10 +++++----- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/ntfy/client.ts b/src/ntfy/client.ts index d44b69e..befa5d1 100644 --- a/src/ntfy/client.ts +++ b/src/ntfy/client.ts @@ -30,17 +30,16 @@ export class NtfyClient { async publish(message: Omit) { try { - await this.httpClient.post( + const response = await this.httpClient.post( '/', JSON.stringify({ topic: this.topic, ...message, }), ) - this.loggerService.debug('Published ntfy-cation', { - topic: this.topic, - message, - }) + if (response.status >= 400) { + throw new Error(`${response.status} - ${response.statusText}`) + } } catch (error: unknown) { this.loggerService.error('ntfy client failed', { error }) } diff --git a/src/ntfy/provider.ts b/src/ntfy/provider.ts index d6e1ad8..b47be76 100644 --- a/src/ntfy/provider.ts +++ b/src/ntfy/provider.ts @@ -36,7 +36,6 @@ export class NtfyProvider implements OnApplicationBootstrap { @Process() async handlePublishJob(job: Job>) { - this.loggerService.debug('Handling publish job', { data: job.data }) await this.ntfyClient.publish({ ...job.data, }) diff --git a/src/ntfy/types.ts b/src/ntfy/types.ts index 813fff6..6e975ab 100644 --- a/src/ntfy/types.ts +++ b/src/ntfy/types.ts @@ -52,11 +52,11 @@ export enum MessageTags { } export enum MessagePriority { - min = '1', - low = '2', - default = '3', - high = '4', - max = '5', + min = 1, + low = 2, + default = 3, + high = 4, + max = 5, } export interface MessageConfig {