Removing some ntfy logs and adding more error handling for 4xx+ errors

This commit is contained in:
Collin Duncan 2024-09-19 13:05:20 +02:00
parent 2c6e275f4c
commit 509462e118
No known key found for this signature in database
3 changed files with 9 additions and 11 deletions

View file

@ -30,17 +30,16 @@ export class NtfyClient {
async publish(message: Omit<MessageConfig, 'topic'>) { async publish(message: Omit<MessageConfig, 'topic'>) {
try { try {
await this.httpClient.post( const response = await this.httpClient.post(
'/', '/',
JSON.stringify({ JSON.stringify({
topic: this.topic, topic: this.topic,
...message, ...message,
}), }),
) )
this.loggerService.debug('Published ntfy-cation', { if (response.status >= 400) {
topic: this.topic, throw new Error(`${response.status} - ${response.statusText}`)
message, }
})
} catch (error: unknown) { } catch (error: unknown) {
this.loggerService.error('ntfy client failed', { error }) this.loggerService.error('ntfy client failed', { error })
} }

View file

@ -36,7 +36,6 @@ export class NtfyProvider implements OnApplicationBootstrap {
@Process() @Process()
async handlePublishJob(job: Job<Omit<MessageConfig, 'topic'>>) { async handlePublishJob(job: Job<Omit<MessageConfig, 'topic'>>) {
this.loggerService.debug('Handling publish job', { data: job.data })
await this.ntfyClient.publish({ await this.ntfyClient.publish({
...job.data, ...job.data,
}) })

View file

@ -52,11 +52,11 @@ export enum MessageTags {
} }
export enum MessagePriority { export enum MessagePriority {
min = '1', min = 1,
low = '2', low = 2,
default = '3', default = 3,
high = '4', high = 4,
max = '5', max = 5,
} }
export interface MessageConfig { export interface MessageConfig {