mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-26 14:32:04 -04:00
(discord) add platform_username and isuser metadata for role-connection
This commit is contained in:
parent
5ee23fb01d
commit
c8948bc078
@ -107,8 +107,6 @@ const buildUserNotFoundResponse = (res: Response) => {
|
||||
};
|
||||
|
||||
const updateMetadata = async (req: Request, res: Response, data: { uid: string, email: string }) => {
|
||||
const metaData = new Map()
|
||||
.set('isTeam', false);
|
||||
const connectedUser = await req.db.get<Pick<User, 'username'>>(
|
||||
SQL`
|
||||
SELECT users.username FROM social_lookup LEFT JOIN users on social_lookup.userId = users.id
|
||||
@ -128,7 +126,10 @@ const updateMetadata = async (req: Request, res: Response, data: { uid: string,
|
||||
if (!user) {
|
||||
return buildUserNotFoundResponse(res);
|
||||
}
|
||||
metaData.set('isTeam', user.roles !== '');
|
||||
const metadata = {
|
||||
isteam: user.roles !== '',
|
||||
isuser: true,
|
||||
};
|
||||
await fetch(
|
||||
`${BASE_DISCORD_URI}/users/@me/applications/${configs.discordClientId}/role-connection`,
|
||||
{
|
||||
@ -139,9 +140,8 @@ const updateMetadata = async (req: Request, res: Response, data: { uid: string,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
platform_name: 'Pronouns.Page',
|
||||
metadata: Object.fromEntries([...metaData.entries()].map(
|
||||
([key, value]) => [key.toLowerCase(), value],
|
||||
)),
|
||||
platform_username: user.username,
|
||||
metadata,
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user