mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-25 05:54:25 -04:00
fix(api-profile-filter): Fix filtering data in profile requests
This commit is contained in:
parent
b1f9f39ca7
commit
8bb0a7fde0
@ -78,20 +78,26 @@ class ProfileOptions {
|
||||
};
|
||||
|
||||
constructor(query_obj, locales) {
|
||||
if (query_obj == null) return;
|
||||
|
||||
const default_props = query_obj["props"];
|
||||
this.default_props = ProfileOptions._parse_props(default_props)
|
||||
|
||||
for (const key of Object.keys(locales)) {
|
||||
const lprops_obj = query_obj["lprops"];
|
||||
let props;
|
||||
if (typeof lprops_obj === "object") {
|
||||
props = lprops_obj[key];
|
||||
} else {
|
||||
props = query_obj[`lprops.${key.toLowerCase()}`];
|
||||
}
|
||||
if (props != null) {
|
||||
this.locale_specific_props[key] = ProfileOptions._parse_props(props);
|
||||
if (locales != null) {
|
||||
for (const key of Object.keys(locales)) {
|
||||
const lprops_obj = query_obj["lprops"];
|
||||
let props;
|
||||
if (typeof lprops_obj === "object") {
|
||||
props = lprops_obj[key];
|
||||
} else {
|
||||
props = query_obj[`lprops.${key.toLowerCase()}`];
|
||||
}
|
||||
if (props != null) {
|
||||
this.locale_specific_props[key] = ProfileOptions._parse_props(props);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.warn("ProfileOptions object was constructed without specifying locales parameter - not providing locale-specific data");
|
||||
}
|
||||
}
|
||||
|
||||
@ -698,7 +704,7 @@ router.post('/profile/save', handleErrorAsync(async (req, res) => {
|
||||
|
||||
await req.db.get(SQL`UPDATE users SET inactiveWarning = null WHERE id = ${req.user.id}`);
|
||||
|
||||
return res.json(await fetchProfiles(req.db, req.user.username, true));
|
||||
return res.json(await fetchProfiles(req.db, req.user.username, true, new ProfileOptions({})));
|
||||
}));
|
||||
|
||||
router.post('/profile/delete/:locale', handleErrorAsync(async (req, res) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user