mirror of
https://github.com/PretendoNetwork/account.git
synced 2026-09-30 14:18:22 -05:00
fix: add try-catch to Discourse data scrubbing
This commit is contained in:
@@ -249,18 +249,22 @@ PNIDSchema.method('scrub', async function scrub() {
|
||||
}
|
||||
|
||||
if (config.discourse.forum_url && config.discourse.api_key && config.discourse.api_username) {
|
||||
const response = await fetch(`${config.discourse.forum_url}/u/by-external/${this.pid}.json`);
|
||||
const json = await response.json();
|
||||
try {
|
||||
const response = await fetch(`${config.discourse.forum_url}/u/by-external/${this.pid}.json`);
|
||||
const json = await response.json();
|
||||
|
||||
if (!json.errors && json.user) {
|
||||
await fetch(`${config.discourse.forum_url}/admin/users/${json.user.id}/anonymize.json`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'Api-Key': config.discourse.api_key,
|
||||
'Api-Username': config.discourse.api_username
|
||||
}
|
||||
});
|
||||
if (!json.errors && json.user) {
|
||||
await fetch(`${config.discourse.forum_url}/admin/users/${json.user.id}/anonymize.json`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'Api-Key': config.discourse.api_key,
|
||||
'Api-Username': config.discourse.api_username
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
LOG_ERROR(`ERROR REMOVING ${this.username} FORUM DATA. ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user