mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-24 05:05:20 -04:00
remove unused normalize
call, and reorganize
This commit is contained in:
parent
eb09bf88bf
commit
1b277468c1
@ -2,7 +2,6 @@ import { Router } from 'express';
|
||||
import type { Request, Response } from 'express';
|
||||
import { handleErrorAsync } from '../../src/helpers.ts';
|
||||
import SQL from 'sql-template-strings';
|
||||
import { normalise } from './user.js';
|
||||
import type { User } from '../../src/user.ts';
|
||||
|
||||
const configs = {
|
||||
@ -90,22 +89,6 @@ const getUserData = async (token: TokenSet) => {
|
||||
};
|
||||
};
|
||||
|
||||
const buildUserNotFoundResponse = (res: Response) => {
|
||||
const error = {
|
||||
code: 404,
|
||||
step: 1,
|
||||
error: 'User not found',
|
||||
hint: [
|
||||
'Try linking your Discord account to your Pronouns.Page account first.\n\n',
|
||||
'After that, on your account settings, select "Login Methods", and ensure the slider saying:',
|
||||
'"Allow getting my profile looked up by social media handles / identifiers',
|
||||
'(it\'s useful for integrations, discord bots, browser extensions, …)" is enabled.\n\n',
|
||||
'If the issue persists, please contact support at support@pronouns.page',
|
||||
].join(' '),
|
||||
};
|
||||
return res.status(error.code).json(error);
|
||||
};
|
||||
|
||||
const updateMetadata = async (req: Request, res: Response, data: { uid: string, email: string }) => {
|
||||
const user = await req.db.get(
|
||||
SQL`
|
||||
@ -114,7 +97,19 @@ const updateMetadata = async (req: Request, res: Response, data: { uid: string,
|
||||
WHERE social_lookup.provider = 'discord' AND social_lookup.identifier = ${data.uid};`,
|
||||
) as Pick<User, 'username' | 'roles'>;
|
||||
if (!user) {
|
||||
return buildUserNotFoundResponse(res);
|
||||
const error = {
|
||||
code: 404,
|
||||
step: 1,
|
||||
error: 'User not found',
|
||||
hint: [
|
||||
'Try linking your Discord account to your Pronouns.Page account first.\n\n',
|
||||
'After that, on your account settings, select "Login Methods", and ensure the slider saying:',
|
||||
'"Allow getting my profile looked up by social media handles / identifiers',
|
||||
'(it\'s useful for integrations, discord bots, browser extensions, …)" is enabled.\n\n',
|
||||
'If the issue persists, please contact support at support@pronouns.page',
|
||||
].join(' '),
|
||||
};
|
||||
return res.status(error.code).json(error);
|
||||
}
|
||||
await fetch(
|
||||
`${BASE_DISCORD_URI}/users/@me/applications/${configs.discordClientId}/role-connection`,
|
||||
|
Loading…
x
Reference in New Issue
Block a user