fix: pr feedback double update

This commit is contained in:
Nicolas Meienberger 2026-05-02 11:48:04 +02:00
parent 589b02ad25
commit 275e1e3d83
No known key found for this signature in database

View file

@ -213,6 +213,7 @@ const updateDeliveryStatus = async (destinationId: number, result: { success: bo
const testDestination = async (id: number) => { const testDestination = async (id: number) => {
const destination = await getDestination(id); const destination = await getDestination(id);
let result: Awaited<ReturnType<typeof sendNotification>>;
try { try {
const decryptedConfig = await decryptNotificationConfig(destination.config); const decryptedConfig = await decryptNotificationConfig(destination.config);
@ -222,21 +223,22 @@ const testDestination = async (id: number) => {
logger.debug("Testing notification with Shoutrrr URL:", shoutrrrUrl); logger.debug("Testing notification with Shoutrrr URL:", shoutrrrUrl);
const result = await sendNotification({ result = await sendNotification({
shoutrrrUrl, shoutrrrUrl,
title: "Zerobyte Test Notification", title: "Zerobyte Test Notification",
body: `This is a test notification from Zerobyte for destination: ${destination.name}`, body: `This is a test notification from Zerobyte for destination: ${destination.name}`,
}); });
await updateDeliveryStatus(destination.id, result);
if (!result.success) {
throw new InternalServerError(`Failed to send test notification: ${result.error}`);
}
} catch (error) { } catch (error) {
await updateDeliveryStatus(destination.id, { success: false, error: toMessage(error) }); await updateDeliveryStatus(destination.id, { success: false, error: toMessage(error) });
throw error; throw error;
} }
await updateDeliveryStatus(destination.id, result);
if (!result.success) {
throw new InternalServerError(`Failed to send test notification: ${result.error}`);
}
return { success: true }; return { success: true };
}; };