add sqlite compatibility + fix whitespace bug collections

This commit is contained in:
Jordan Higuera Higuera
2023-08-03 21:33:51 -07:00
parent 264ea03e63
commit 22093c0c29
8 changed files with 130 additions and 67 deletions
+11 -2
View File
@@ -17,14 +17,23 @@ export default async function getUser({
id: params.lookupId,
username: params.lookupUsername?.toLowerCase(),
},
include: {
whitelistedUsers: {
select: {
username: true
}
}
}
});
if (!user) return { response: "User not found.", status: 404 };
const whitelistedUsernames = user.whitelistedUsers?.map(usernames => usernames.username);
if (
!isSelf &&
user?.isPrivate &&
!user.whitelistedUsers.includes(username.toLowerCase())
!whitelistedUsernames.includes(username.toLowerCase())
) {
return { response: "This profile is private.", status: 401 };
}
@@ -33,7 +42,7 @@ export default async function getUser({
const data = isSelf
? // If user is requesting its own data
lessSensitiveInfo
{...lessSensitiveInfo, whitelistedUsers: whitelistedUsernames}
: {
// If user is requesting someone elses data
id: lessSensitiveInfo.id,