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;
}
|