Handle raw response from idnot
This commit is contained in:
parent
6344f6be15
commit
b96720c0af
@ -227,21 +227,29 @@ export default class IdNotService extends BaseService {
|
|||||||
key: this.variables.IDNOT_API_KEY,
|
key: this.variables.IDNOT_API_KEY,
|
||||||
});
|
});
|
||||||
|
|
||||||
let userData: IRattachementData;
|
let userRawData: Response;
|
||||||
try {
|
try {
|
||||||
userData = (await (
|
userRawData = await fetch(
|
||||||
await fetch(
|
|
||||||
`${this.variables.IDNOT_API_BASE_URL}/api/pp/v2/rattachements/${user.idNot}_${user.office_membership!.idNot}?` +
|
`${this.variables.IDNOT_API_BASE_URL}/api/pp/v2/rattachements/${user.idNot}_${user.office_membership!.idNot}?` +
|
||||||
searchParams,
|
searchParams,
|
||||||
{
|
{
|
||||||
method: "GET",
|
method: "GET",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
).json()) as IRattachementData;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error fetching user data for ${user.uid}: ${error}`);
|
console.error(`Error fetching user data for ${user.uid}: ${error}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (userRawData.status === 404) {
|
||||||
|
console.error(`User ${user.uid} not found in idnot`);
|
||||||
|
return;
|
||||||
|
} else if (userRawData.status !== 200) {
|
||||||
|
console.error(`Error fetching user data for ${user.uid}: ${userRawData.status} - ${userRawData.statusText}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let userData = (await userRawData.json()) as IRattachementData;
|
||||||
|
|
||||||
console.log("Got userData from idnot", JSON.stringify(userData));
|
console.log("Got userData from idnot", JSON.stringify(userData));
|
||||||
|
|
||||||
@ -249,16 +257,22 @@ export default class IdNotService extends BaseService {
|
|||||||
let rattachements: any;
|
let rattachements: any;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
rattachements = (await (
|
rattachements = await fetch(`${this.variables.IDNOT_API_BASE_URL}/api/pp/v2/personnes/${user.idNot}/rattachements?deleted=false` + searchParams, {
|
||||||
await fetch(`${this.variables.IDNOT_API_BASE_URL}/api/pp/v2/personnes/${user.idNot}/rattachements?deleted=false` + searchParams, {
|
method: "GET",
|
||||||
method: "GET",
|
});
|
||||||
})
|
|
||||||
).json()) as any;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching rattachements", error);
|
console.error("Error fetching rattachements", error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rattachements.status === 404) {
|
||||||
|
console.error(`User ${user.uid} not found in idnot`);
|
||||||
|
return;
|
||||||
|
} else if (rattachements.status !== 200) {
|
||||||
|
console.error(`Error fetching rattachements for ${user.uid}: ${rattachements.status} - ${rattachements.statusText}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (rattachements.totalResultCount === 0) {
|
if (rattachements.totalResultCount === 0) {
|
||||||
console.warn("User has no valid rattachements", user.uid);
|
console.warn("User has no valid rattachements", user.uid);
|
||||||
await this.userService.updateCheckedAt(user.uid!);
|
await this.userService.updateCheckedAt(user.uid!);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user