summary refs log tree commit diff
path: root/src/api/routes
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-04-19 22:14:01 +0200
committerRory& <root@rory.gay>2026-04-19 22:45:37 +0200
commitaf29e6b178493c4d323edb9a7838d7731e40df86 (patch)
tree70e1357da5d86d72c29ba3dcfa0277e7519a8d44 /src/api/routes
parenteslint: no-promise-executor-return (diff)
downloadserver-ts-af29e6b178493c4d323edb9a7838d7731e40df86.tar.xz
eslint: arrow-body-style=as-needed
Diffstat (limited to 'src/api/routes')
-rw-r--r--src/api/routes/attachments/refresh-urls.ts8
-rw-r--r--src/api/routes/auth/verify/resend.ts4
-rw-r--r--src/api/routes/channels/#channel_id/attachments.ts14
-rw-r--r--src/api/routes/guilds/#guild_id/widget.json.ts26
-rw-r--r--src/api/routes/users/@me/mentions.ts24
-rw-r--r--src/api/routes/users/@me/mfa/webauthn/credentials/index.ts9
-rw-r--r--src/api/routes/users/@me/relationships.ts14
7 files changed, 42 insertions, 57 deletions
diff --git a/src/api/routes/attachments/refresh-urls.ts b/src/api/routes/attachments/refresh-urls.ts

index 38bbf8d7..8f43c8ca 100644 --- a/src/api/routes/attachments/refresh-urls.ts +++ b/src/api/routes/attachments/refresh-urls.ts
@@ -38,8 +38,8 @@ router.post( (req: Request, res: Response) => { const { attachment_urls } = req.body as RefreshUrlsRequestSchema; - const refreshed_urls = attachment_urls.map((url) => { - return getUrlSignature( + const refreshed_urls = attachment_urls.map((url) => + getUrlSignature( new NewUrlSignatureData({ url: url, ip: req.ip, @@ -47,8 +47,8 @@ router.post( }), ) .applyToUrl(url) - .toString(); - }); + .toString(), + ); return res.status(200).json({ refreshed_urls, diff --git a/src/api/routes/auth/verify/resend.ts b/src/api/routes/auth/verify/resend.ts
index 453c616d..0d647be9 100644 --- a/src/api/routes/auth/verify/resend.ts +++ b/src/api/routes/auth/verify/resend.ts
@@ -52,9 +52,7 @@ router.post( } await Email.sendVerifyEmail(user, user.email) - .then(() => { - return res.sendStatus(204); - }) + .then(() => res.sendStatus(204)) .catch((e) => { console.error(`Failed to send verification email to ${user.tag}: ${e}`); throw new HTTPError("Failed to send verification email", 500); diff --git a/src/api/routes/channels/#channel_id/attachments.ts b/src/api/routes/channels/#channel_id/attachments.ts
index 7e59c0a6..3bb3fc19 100644 --- a/src/api/routes/channels/#channel_id/attachments.ts +++ b/src/api/routes/channels/#channel_id/attachments.ts
@@ -86,14 +86,12 @@ router.post( ); res.send({ - attachments: attachments.map((a) => { - return { - id: a.userAttachmentId, - upload_filename: a.uploadFilename, - upload_url: `${cdnUrl}/attachments/${a.uploadFilename}`, - original_content_type: a.userOriginalContentType, - }; - }), + attachments: attachments.map((a) => ({ + id: a.userAttachmentId, + upload_filename: a.uploadFilename, + upload_url: `${cdnUrl}/attachments/${a.uploadFilename}`, + original_content_type: a.userOriginalContentType, + })), } as UploadAttachmentResponseSchema); }, ); diff --git a/src/api/routes/guilds/#guild_id/widget.json.ts b/src/api/routes/guilds/#guild_id/widget.json.ts
index 0df3f3c0..f1741e88 100644 --- a/src/api/routes/guilds/#guild_id/widget.json.ts +++ b/src/api/routes/guilds/#guild_id/widget.json.ts
@@ -126,20 +126,18 @@ async function getWidgetJsonData(guild_id: string) { const minLastSeen = Date.now() - 1000 * 60 * 5; const onlineMembers = members.filter((m) => m.user.sessions.filter((s) => (s.last_seen?.getTime() ?? 0) > minLastSeen).length > 0); const memberData = onlineMembers - .map((x) => { - return { - id: x.id, - username: x.user.username, - discriminator: x.user.discriminator, - avatar: null, - status: "online", // TODO - avatar_url: x.avatar - ? `${Config.get().cdn.endpointPublic}/guilds/${guild_id}/users/${x.id}/avatars/${x.avatar}.png` - : x.user.avatar - ? `${Config.get().cdn.endpointPublic}/avatars/${x.id}/${x.user.avatar}.png` - : `${Config.get().cdn.endpointPublic}/embed/avatars/${BigInt(x.id) % 6n}.png`, - }; - }) + .map((x) => ({ + id: x.id, + username: x.user.username, + discriminator: x.user.discriminator, + avatar: null, + status: "online", // TODO + avatar_url: x.avatar + ? `${Config.get().cdn.endpointPublic}/guilds/${guild_id}/users/${x.id}/avatars/${x.avatar}.png` + : x.user.avatar + ? `${Config.get().cdn.endpointPublic}/avatars/${x.id}/${x.user.avatar}.png` + : `${Config.get().cdn.endpointPublic}/embed/avatars/${BigInt(x.id) % 6n}.png`, + })) .sort((a, b) => Number(BigInt(a.id) - BigInt(b.id))); // Construct object to respond with diff --git a/src/api/routes/users/@me/mentions.ts b/src/api/routes/users/@me/mentions.ts
index d3c05b44..87602b3c 100644 --- a/src/api/routes/users/@me/mentions.ts +++ b/src/api/routes/users/@me/mentions.ts
@@ -137,20 +137,18 @@ router.get( }, take: limit, }) - ).map((m) => { - return { - ...m.toJSON(), - attachments: m.attachments?.map((attachment: Attachment) => - Attachment.prototype.signUrls.call( - attachment, - new NewUrlUserSignatureData({ - ip: req.ip, - userAgent: req.headers["user-agent"] as string, - }), - ), + ).map((m) => ({ + ...m.toJSON(), + attachments: m.attachments?.map((attachment: Attachment) => + Attachment.prototype.signUrls.call( + attachment, + new NewUrlUserSignatureData({ + ip: req.ip, + userAgent: req.headers["user-agent"] as string, + }), ), - }; - }); + ), + })); console.log(`[Inbox/mentions] User ${user.id} fetched full message data for ${finalMessages.length} messages in ${sw.elapsed().totalMilliseconds}ms`); diff --git a/src/api/routes/users/@me/mfa/webauthn/credentials/index.ts b/src/api/routes/users/@me/mfa/webauthn/credentials/index.ts
index f99f7b3d..778fb9d8 100644 --- a/src/api/routes/users/@me/mfa/webauthn/credentials/index.ts +++ b/src/api/routes/users/@me/mfa/webauthn/credentials/index.ts
@@ -25,13 +25,8 @@ import { HTTPError } from "lambert-server"; import { CreateWebAuthnCredentialSchema, GenerateWebAuthnCredentialsSchema, WebAuthnPostSchema } from "@spacebar/schemas"; const router = Router({ mergeParams: true }); -const isGenerateSchema = (body: WebAuthnPostSchema): body is GenerateWebAuthnCredentialsSchema => { - return "password" in body; -}; - -const isCreateSchema = (body: WebAuthnPostSchema): body is CreateWebAuthnCredentialSchema => { - return "credential" in body; -}; +const isGenerateSchema = (body: WebAuthnPostSchema): body is GenerateWebAuthnCredentialsSchema => "password" in body; +const isCreateSchema = (body: WebAuthnPostSchema): body is CreateWebAuthnCredentialSchema => "credential" in body; function toArrayBuffer(buf: Buffer) { const ab = new ArrayBuffer(buf.length); diff --git a/src/api/routes/users/@me/relationships.ts b/src/api/routes/users/@me/relationships.ts
index e049d152..5da62ce8 100644 --- a/src/api/routes/users/@me/relationships.ts +++ b/src/api/routes/users/@me/relationships.ts
@@ -64,8 +64,8 @@ router.put( }, }, }), - async (req: Request, res: Response) => { - return await updateRelationship( + async (req: Request, res: Response) => + await updateRelationship( req, res, await User.findOneOrFail({ @@ -74,8 +74,7 @@ router.put( select: userProjection, }), req.body.type ?? RelationshipType.friends, - ); - }, + ), ); router.patch( @@ -130,8 +129,8 @@ router.post( }, }, }), - async (req: Request, res: Response) => { - return await updateRelationship( + async (req: Request, res: Response) => + await updateRelationship( req, res, await User.findOneOrFail({ @@ -143,8 +142,7 @@ router.post( }, }), req.body.type, - ); - }, + ), ); router.delete(