Removing some ntfy logs and adding more error handling for 4xx+ errors
This commit is contained in:
parent
2c6e275f4c
commit
509462e118
3 changed files with 9 additions and 11 deletions
|
|
@ -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 })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue