-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
}) |