summary refs log tree commit diff
path: root/src/api/routes/applications/#id/bot/index.ts
diff options
context:
space:
mode:
authorEmma [it/its]@Rory& <root@rory.gay>2023-12-11 01:12:54 +0100
committerEmma [it/its]@Rory& <root@rory.gay>2023-12-11 01:12:54 +0100
commit0a8ceb9e6349284e75545a01ffad608b020f78e2 (patch)
tree17a9163f963eddabf9168b0b630096b2f7535b64 /src/api/routes/applications/#id/bot/index.ts
parentPrettier: use editorconfig (diff)
downloadserver-0a8ceb9e6349284e75545a01ffad608b020f78e2.tar.xz
Actually run prettier dev/emma-refactors
Diffstat (limited to 'src/api/routes/applications/#id/bot/index.ts')
-rw-r--r--src/api/routes/applications/#id/bot/index.ts26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/api/routes/applications/#id/bot/index.ts b/src/api/routes/applications/#id/bot/index.ts
index 3c431e3d..5d58e6ed 100644
--- a/src/api/routes/applications/#id/bot/index.ts
+++ b/src/api/routes/applications/#id/bot/index.ts
@@ -50,15 +50,14 @@ router.post(
 			relations: ["owner"],
 		});
 
-		if (app.owner.id != req.user_id)
-			throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
+		if (app.owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
 
 		const user = await createAppBotUser(app, req);
 
 		res.send({
 			token: await generateToken(user.id),
 		}).status(204);
-	},
+	}
 );
 
 router.post(
@@ -77,13 +76,9 @@ router.post(
 		const bot = await User.findOneOrFail({ where: { id: req.params.id } });
 		const owner = await User.findOneOrFail({ where: { id: req.user_id } });
 
-		if (owner.id != req.user_id)
-			throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
+		if (owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
 
-		if (
-			owner.totp_secret &&
-			(!req.body.code || verifyToken(owner.totp_secret, req.body.code))
-		)
+		if (owner.totp_secret && (!req.body.code || verifyToken(owner.totp_secret, req.body.code)))
 			throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008);
 
 		bot.data = { hash: undefined, valid_tokens_since: new Date() };
@@ -93,7 +88,7 @@ router.post(
 		const token = await generateToken(bot.id);
 
 		res.json({ token }).status(200);
-	},
+	}
 );
 
 router.patch(
@@ -120,14 +115,9 @@ router.patch(
 
 		if (!app.bot) throw DiscordApiErrors.BOT_ONLY_ENDPOINT;
 
-		if (app.owner.id != req.user_id)
-			throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
+		if (app.owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
 
-		if (body.avatar)
-			body.avatar = await handleFile(
-				`/avatars/${app.id}`,
-				body.avatar as string,
-			);
+		if (body.avatar) body.avatar = await handleFile(`/avatars/${app.id}`, body.avatar as string);
 
 		app.bot.assign(body);
 
@@ -135,7 +125,7 @@ router.patch(
 
 		await app.save();
 		res.json(app).status(200);
-	},
+	}
 );
 
 export default router;