From 881ad1b44df4e1aa9ce750468ad41c9581349662 Mon Sep 17 00:00:00 2001 From: dbarkowsky Date: Wed, 11 Dec 2024 11:15:41 -0800 Subject: [PATCH 1/2] add notification tool script --- tools/bulkEmailResend/resendEmails.ts | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tools/bulkEmailResend/resendEmails.ts diff --git a/tools/bulkEmailResend/resendEmails.ts b/tools/bulkEmailResend/resendEmails.ts new file mode 100644 index 000000000..bad40477d --- /dev/null +++ b/tools/bulkEmailResend/resendEmails.ts @@ -0,0 +1,30 @@ +/** + * This script takes from a JSON list of notifications and resends those notifications. + * The only necessary property of the notification is the "id". + * Get the token from your browser session. You must be an admin for this to work. + * Drop the JSON file in this same folder and adjust the file name to use. + */ + +import notifsToResend from './notif_ids_to_resend.json' with { type: "json" }; + +const token = ""; + +const targetUrl = "https://pims.gov.bc.ca/api/v2/notifications/queue" + +notifsToResend.forEach(notif => { + fetch(`${targetUrl}/${notif.id}`, { + method: 'PUT', + headers: { + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json', + }, + }).then(async (value: Response) => { + if (value.status == 200){ + console.log(notif.id, "Success") + } else { + console.log(notif.id, value.status, await value.text()) + } + }).catch((reason: any) => { + console.log(notif.id, reason) + }) +}) From 0c6889d4f6e88ad677759ed14d94ea33901cc241 Mon Sep 17 00:00:00 2001 From: dbarkowsky Date: Wed, 11 Dec 2024 11:18:52 -0800 Subject: [PATCH 2/2] note about Deno --- tools/bulkEmailResend/resendEmails.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/bulkEmailResend/resendEmails.ts b/tools/bulkEmailResend/resendEmails.ts index bad40477d..5bcb9d7a4 100644 --- a/tools/bulkEmailResend/resendEmails.ts +++ b/tools/bulkEmailResend/resendEmails.ts @@ -3,6 +3,7 @@ * The only necessary property of the notification is the "id". * Get the token from your browser session. You must be an admin for this to work. * Drop the JSON file in this same folder and adjust the file name to use. + * I ran this using Deno. Adjustments may be needed with other runtimes. */ import notifsToResend from './notif_ids_to_resend.json' with { type: "json" };