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(
diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts
index 3ebf50e4..32f1e3d7 100644
--- a/src/api/util/handlers/Message.ts
+++ b/src/api/util/handlers/Message.ts
@@ -562,24 +562,9 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
/*message.mention_channels = mention_channel_ids.map((x) =>
Channel.create({ id: x }),
);*/
- message.mention_roles = (
- await Promise.all(
- mention_role_ids.map((x) => {
- return Role.findOne({ where: { id: x } });
- }),
- )
- ).filter((role) => role !== null);
+ message.mention_roles = (await Promise.all(mention_role_ids.map((x) => Role.findOne({ where: { id: x } })))).filter((role) => role !== null);
- message.mentions = [
- ...message.mentions,
- ...(
- await Promise.all(
- mention_user_ids.map((x) => {
- return User.findOne({ where: { id: x } });
- }),
- )
- ).filter((user) => user !== null),
- ];
+ message.mentions = [...message.mentions, ...(await Promise.all(mention_user_ids.map((x) => User.findOne({ where: { id: x } })))).filter((user) => user !== null)];
message.mention_everyone = mention_everyone;
async function fillInMissingIDs(ids: string[]) {
@@ -592,11 +577,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
if (!users.size) {
return;
}
- return Promise.all(
- [...users].map((user_id) => {
- return ReadState.create({ user_id, channel_id: channel.id }).save();
- }),
- );
+ return Promise.all([...users].map((user_id) => ReadState.create({ user_id, channel_id: channel.id }).save()));
}
if (ephermal) {
const id = message.interaction_metadata?.user_id;
@@ -624,11 +605,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
const users = new Set<string>([
...(message.mention_roles.length
? await Member.find({
- where: [
- ...message.mention_roles.map((role) => {
- return { roles: { id: role.id } };
- }),
- ],
+ where: [...message.mention_roles.map((role) => ({ roles: { id: role.id } }))],
})
: []
).map((member) => member.id),
@@ -647,11 +624,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
}
}
- const attachmentIndices = new Map(
- message.attachments?.map((attachment, index) => {
- return [`attachment://${attachment.filename}`, index];
- }),
- );
+ const attachmentIndices = new Map(message.attachments?.map((attachment, index) => [`attachment://${attachment.filename}`, index]));
const attachmentsToRemove = new Set<number>();
function fetchAttachment(url: string | undefined): Attachment | undefined {
if (url == undefined) {
@@ -690,9 +663,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
author!.proxy_icon_url = authorAttachment.toJSON().proxy_url;
}
}
- message.attachments = message.attachments?.filter((_, index) => {
- return !attachmentsToRemove.has(index);
- });
+ message.attachments = message.attachments?.filter((_, index) => !attachmentsToRemove.has(index));
// TODO: check and put it all in the body
diff --git a/src/api/util/utility/EmbedHandlers.ts b/src/api/util/utility/EmbedHandlers.ts
index e9165a13..f242d686 100644
--- a/src/api/util/utility/EmbedHandlers.ts
+++ b/src/api/util/utility/EmbedHandlers.ts
@@ -603,9 +603,7 @@ export async function getOrUpdateEmbedCache(urls: string[], cb?: (url: string, e
.filter((e) => e !== undefined),
);
- const urlsToGenerate = urls.filter((url) => {
- return !cachedEmbeds.some((e) => e.url == normalizeUrl(url));
- });
+ const urlsToGenerate = urls.filter((url) => !cachedEmbeds.some((e) => e.url == normalizeUrl(url)));
if (urlsToGenerate.length > 0) console.log("[Embeds] Need to generate embeds for urls:", urlsToGenerate);
if (cachedEmbeds.length > 0)
|