mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-27 06:52:35 -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 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'>>(
|
const connectedUser = await req.db.get<Pick<User, 'username'>>(
|
||||||
SQL`
|
SQL`
|
||||||
SELECT users.username FROM social_lookup LEFT JOIN users on social_lookup.userId = users.id
|
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) {
|
if (!user) {
|
||||||
return buildUserNotFoundResponse(res);
|
return buildUserNotFoundResponse(res);
|
||||||
}
|
}
|
||||||
metaData.set('isTeam', user.roles !== '');
|
const metadata = {
|
||||||
|
isteam: user.roles !== '',
|
||||||
|
isuser: true,
|
||||||
|
};
|
||||||
await fetch(
|
await fetch(
|
||||||
`${BASE_DISCORD_URI}/users/@me/applications/${configs.discordClientId}/role-connection`,
|
`${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({
|
body: JSON.stringify({
|
||||||
platform_name: 'Pronouns.Page',
|
platform_name: 'Pronouns.Page',
|
||||||
metadata: Object.fromEntries([...metaData.entries()].map(
|
platform_username: user.username,
|
||||||
([key, value]) => [key.toLowerCase(), value],
|
metadata,
|
||||||
)),
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user