Skip to content

Commit

Permalink
Merge branch 'main' into PIMS-2256
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharala-Perumal authored Dec 17, 2024
2 parents 69e9e0a + 1932f6e commit afc2daf
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tools/bulkEmailResend/resendEmails.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* 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.
* I ran this using Deno. Adjustments may be needed with other runtimes.
*/

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

0 comments on commit afc2daf

Please sign in to comment.