summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-10-03 20:50:48 +0200
committerRory& <root@rory.gay>2025-10-04 19:09:26 +0200
commita25393e80683dbb1d2b9e305af624aa3752050d6 (patch)
treed9ab5fa79a8e89d49fb70587ac6772ec7fe99cc8 /src/api
parentAdd Array.remove extension (diff)
downloadserver-ts-a25393e80683dbb1d2b9e305af624aa3752050d6.tar.xz
Clean up array extensions
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/channels/#channel_id/recipients.ts2
-rw-r--r--src/api/routes/channels/#channel_id/typing.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/roles/#role_id/members.ts5
-rw-r--r--src/api/util/utility/passwordStrength.ts10
4 files changed, 9 insertions, 10 deletions
diff --git a/src/api/routes/channels/#channel_id/recipients.ts b/src/api/routes/channels/#channel_id/recipients.ts

index 025a86f6..14ab28e5 100644 --- a/src/api/routes/channels/#channel_id/recipients.ts +++ b/src/api/routes/channels/#channel_id/recipients.ts
@@ -51,7 +51,7 @@ router.put( const recipients = [ ...(channel.recipients?.map((r) => r.user_id) || []), user_id, - ].unique(); + ].distinct(); const new_channel = await Channel.createDMChannel( recipients, diff --git a/src/api/routes/channels/#channel_id/typing.ts b/src/api/routes/channels/#channel_id/typing.ts
index 7e6cba41..7ef36150 100644 --- a/src/api/routes/channels/#channel_id/typing.ts +++ b/src/api/routes/channels/#channel_id/typing.ts
@@ -35,7 +35,7 @@ router.post( async (req: Request, res: Response) => { const { channel_id } = req.params; const user_id = req.user_id; - const timestamp = Date.nowSeconds(); + const timestamp = Math.floor(Date.now() / 1000); const channel = await Channel.findOneOrFail({ where: { id: channel_id }, }); diff --git a/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts b/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts
index b1506b0b..4cfe21b9 100644 --- a/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts +++ b/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts
@@ -17,7 +17,7 @@ */ import { Router, Request, Response } from "express"; -import { DiscordApiErrors, Member, partition } from "@spacebar/util"; +import { DiscordApiErrors, Member } from "@spacebar/util"; import { route } from "@spacebar/api"; const router = Router({ mergeParams: true }); @@ -38,8 +38,7 @@ router.patch( relations: ["roles"], }); - const [add, remove] = partition( - members, + const [add, remove] = members.partition( (member) => member_ids.includes(member.id) && !member.roles.map((role) => role.id).includes(role_id), diff --git a/src/api/util/utility/passwordStrength.ts b/src/api/util/utility/passwordStrength.ts
index fcd42d8d..f48b8022 100644 --- a/src/api/util/utility/passwordStrength.ts +++ b/src/api/util/utility/passwordStrength.ts
@@ -20,7 +20,7 @@ import { Config } from "@spacebar/util"; const reNUMBER = /[0-9]/g; const reUPPERCASELETTER = /[A-Z]/g; -const reSYMBOLS = /[A-Z,a-z,0-9]/g; +const reSYMBOLS = /[A-Za-z0-9]/g; // const blocklist: string[] = []; // TODO: update ones passwordblocklist is stored in db /* @@ -45,12 +45,12 @@ export function checkPassword(password: string): number { } // checks for amount of Numbers - if (password.count(reNUMBER) >= minNumbers - 1) { + if (password.match(reNUMBER)?.length ?? 0 >= minNumbers - 1) { strength += 0.05; } // checks for amount of Uppercase Letters - if (password.count(reUPPERCASELETTER) >= minUpperCase - 1) { + if (password.match(reUPPERCASELETTER)?.length ?? 0 >= minUpperCase - 1) { strength += 0.05; } @@ -61,8 +61,8 @@ export function checkPassword(password: string): number { // checks if password only consists of numbers or only consists of chars if ( - password.length == password.count(reNUMBER) || - password.length === password.count(reUPPERCASELETTER) + password.length == password.match(reNUMBER)?.length || + password.length === password.match(reUPPERCASELETTER)?.length ) { strength = 0; }