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'>) {
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 })
}

View file

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

View file

@ -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 {