Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIMS-2252 Notification Script #2880

Merged
merged 4 commits into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
})
})
Loading