Log invalid deliveries
ci/woodpecker/tag/ociImageTag Pipeline is running Details

This commit is contained in:
Natty 2024-01-08 02:23:25 +01:00
parent e7ff3a81bb
commit 3fe46dc6f9
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
1 changed files with 20 additions and 12 deletions

View File

@ -18,16 +18,17 @@ import { endedPollNotification } from "./processors/ended-poll-notification.js";
import {queueLogger} from "./logger.js"; import {queueLogger} from "./logger.js";
import {getJobInfo} from "./get-job-info.js"; import {getJobInfo} from "./get-job-info.js";
import { import {
systemQueue, backgroundQueue,
dbQueue, dbQueue,
deliverQueue, deliverQueue,
endedPollNotificationQueue,
inboxQueue, inboxQueue,
objectStorageQueue, objectStorageQueue,
endedPollNotificationQueue, systemQueue,
webhookDeliverQueue, webhookDeliverQueue,
backgroundQueue,
} from "./queues.js"; } from "./queues.js";
import type {ThinUser} from "./types.js"; import type {ThinUser} from "./types.js";
import {URL} from "node:url";
function renderError(e: Error): any { function renderError(e: Error): any {
return { return {
@ -169,6 +170,13 @@ export function deliver(user: ThinUser, content: unknown, to: string | null) {
to, to,
}; };
try {
new URL(data.to);
} catch (e) {
deliverLogger.error(`Failed URL parse, incorrect data: ${JSON.stringify(data)}`);
return null;
}
return deliverQueue.add(data, { return deliverQueue.add(data, {
attempts: config.deliverJobMaxAttempts || 12, attempts: config.deliverJobMaxAttempts || 12,
timeout: 1 * 60 * 1000, // 1min timeout: 1 * 60 * 1000, // 1min