summary refs log tree commit diff
path: root/util/src
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-06 18:25:30 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-09 23:28:27 +0200
commitcba3844c6f7a6b26c93d8061da0ca7fe6b291e92 (patch)
tree515a4000f4d26ab1999644b9dd6a057e03041bcf /util/src
parentmigrate to DataSource (diff)
downloadserver-cba3844c6f7a6b26c93d8061da0ca7fe6b291e92.tar.xz
Resolve changes undone by rebasing from master
Diffstat (limited to 'util/src')
-rw-r--r--util/src/entities/Channel.ts4
-rw-r--r--util/src/entities/Invite.ts2
-rw-r--r--util/src/entities/Member.ts8
-rw-r--r--util/src/entities/Message.ts1
-rw-r--r--util/src/util/Token.ts8
5 files changed, 11 insertions, 12 deletions
diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts
index 2a1e38a4..5ccb43ce 100644
--- a/util/src/entities/Channel.ts
+++ b/util/src/entities/Channel.ts
@@ -169,7 +169,7 @@ export class Channel extends BaseClass {
 		}

 

 		if (!opts?.skipNameChecks) {

-			const guild = await Guild.findOneOrFail({ id: channel.guild_id });

+			const guild = await Guild.findOneOrFail({ where: { id: channel.guild_id } });

 			if (!guild.features.includes("ALLOW_INVALID_CHANNEL_NAMES") && channel.name) {

 				for (let character of InvisibleCharacters)

 					if (channel.name.includes(character))

@@ -194,7 +194,7 @@ export class Channel extends BaseClass {
 			case ChannelType.GUILD_NEWS:

 			case ChannelType.GUILD_VOICE:

 				if (channel.parent_id && !opts?.skipExistsCheck) {

-					const exists = await Channel.findOneOrFail({ id: channel.parent_id });

+					const exists = await Channel.findOneOrFail({ where: { id: channel.parent_id } });

 					if (!exists) throw new HTTPError("Parent id channel doesn't exist", 400);

 					if (exists.guild_id !== channel.guild_id)

 						throw new HTTPError("The category channel needs to be in the guild");

diff --git a/util/src/entities/Invite.ts b/util/src/entities/Invite.ts
index 6ac64ddc..b672caf7 100644
--- a/util/src/entities/Invite.ts
+++ b/util/src/entities/Invite.ts
@@ -75,7 +75,7 @@ export class Invite extends BaseClassWithoutId {
 	vanity_url?: boolean;
 
 	static async joinGuild(user_id: string, code: string) {
-		const invite = await Invite.findOneOrFail({ code });
+		const invite = await Invite.findOneOrFail({ where: { code } });
 		if (invite.uses++ >= invite.max_uses && invite.max_uses !== 0) await Invite.delete({ code });
 		else await invite.save();
 
diff --git a/util/src/entities/Member.ts b/util/src/entities/Member.ts
index f6d99125..e7e97b7c 100644
--- a/util/src/entities/Member.ts
+++ b/util/src/entities/Member.ts
@@ -117,7 +117,7 @@ export class Member extends BaseClassWithoutId {
 	// read_state: ReadState;
 
 	static async IsInGuildOrFail(user_id: string, guild_id: string) {
-		if (await Member.count({ id: user_id, guild: { id: guild_id } })) return true;
+		if (await Member.count({ where: { id: user_id, guild: { id: guild_id } } })) return true;
 		throw new HTTPError("You are not member of this guild", 403);
 	}
 
@@ -183,7 +183,7 @@ export class Member extends BaseClassWithoutId {
 				relations: ["user", "roles"], // we don't want to load  the role objects just the ids
 				select: ["index"],
 			}),
-			await Role.findOneOrFail({ id: role_id, guild_id }),
+			await Role.findOneOrFail({ where: { id: role_id, guild_id } }),
 		]);
 		member.roles = member.roles.filter((x) => x.id == role_id);
 
@@ -233,7 +233,7 @@ export class Member extends BaseClassWithoutId {
 			throw DiscordApiErrors.USER_BANNED;
 		}
 		const { maxGuilds } = Config.get().limits.user;
-		const guild_count = await Member.count({ id: user_id });
+		const guild_count = await Member.count({ where: { id: user_id } });
 		if (guild_count >= maxGuilds) {
 			throw new HTTPError(`You are at the ${maxGuilds} server limit.`, 403);
 		}
@@ -245,7 +245,7 @@ export class Member extends BaseClassWithoutId {
 			relations: PublicGuildRelations,
 		});
 
-		if (await Member.count({ id: user.id, guild: { id: guild_id } }))
+		if (await Member.count({ where: { id: user.id, guild: { id: guild_id } } }))
 			throw new HTTPError("You are already a member of this guild", 400);
 
 		const member = {
diff --git a/util/src/entities/Message.ts b/util/src/entities/Message.ts
index e18cf691..ba3d4f2d 100644
--- a/util/src/entities/Message.ts
+++ b/util/src/entities/Message.ts
@@ -8,7 +8,6 @@ import {
 	Column,
 	CreateDateColumn,
 	Entity,
-	FindConditions,
 	Index,
 	JoinColumn,
 	JoinTable,
diff --git a/util/src/util/Token.ts b/util/src/util/Token.ts
index 500ace45..5a3922d1 100644
--- a/util/src/util/Token.ts
+++ b/util/src/util/Token.ts
@@ -15,10 +15,10 @@ export function checkToken(token: string, jwtSecret: string): Promise<any> {
 		jwt.verify(token, jwtSecret, JWTOptions, async (err, decoded: any) => {
 			if (err || !decoded) return rej("Invalid Token");
 
-			const user = await User.findOne(
-				{ id: decoded.id },
-				{ select: ["data", "bot", "disabled", "deleted", "rights"] }
-			);
+			const user = await User.findOne({
+				where: { id: decoded.id },
+				select: ["data", "bot", "disabled", "deleted", "rights"] 
+			});
 			if (!user) return rej("Invalid Token");
 			// we need to round it to seconds as it saved as seconds in jwt iat and valid_tokens_since is stored in milliseconds
 			if (decoded.iat * 1000 < new Date(user.data.valid_tokens_since).setSeconds(0, 0))