summary refs log tree commit diff
path: root/src/api/routes/users/@me/relationships.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/routes/users/@me/relationships.ts')
-rw-r--r--src/api/routes/users/@me/relationships.ts39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/api/routes/users/@me/relationships.ts b/src/api/routes/users/@me/relationships.ts
index f7464b99..8267c142 100644
--- a/src/api/routes/users/@me/relationships.ts
+++ b/src/api/routes/users/@me/relationships.ts
@@ -1,18 +1,18 @@
+import { route } from "@fosscord/api";
 import {
-	RelationshipAddEvent,
-	User,
-	PublicUserProjection,
-	RelationshipType,
-	RelationshipRemoveEvent,
+	Config,
+	DiscordApiErrors,
 	emitEvent,
+	HTTPError,
+	OrmUtils,
+	PublicUserProjection,
 	Relationship,
-	Config
+	RelationshipAddEvent,
+	RelationshipRemoveEvent,
+	RelationshipType,
+	User
 } from "@fosscord/util";
-import { Router, Response, Request } from "express";
-import { HTTPError } from "@fosscord/util";
-import { DiscordApiErrors } from "@fosscord/util";
-import { route } from "@fosscord/api";
-import { OrmUtils } from "@fosscord/util";
+import { Request, Response, Router } from "express";
 
 const router = Router();
 
@@ -42,7 +42,11 @@ router.put("/:id", route({ body: "RelationshipPutSchema" }), async (req: Request
 	return await updateRelationship(
 		req,
 		res,
-		await User.findOneOrFail({ where: { id: req.params.id }, relations: ["relationships", "relationships.to"], select: userProjection }),
+		await User.findOneOrFail({
+			where: { id: req.params.id },
+			relations: ["relationships", "relationships.to"],
+			select: userProjection
+		}),
 		req.body.type ?? RelationshipType.friends
 	);
 });
@@ -132,7 +136,9 @@ async function updateRelationship(req: Request, res: Response, friend: User, typ
 			relationship.type = RelationshipType.blocked;
 			await relationship.save();
 		} else {
-			relationship = await (OrmUtils.mergeDeep(new Relationship(), { to_id: id, type: RelationshipType.blocked, from_id: req.user_id }) as Relationship).save();
+			relationship = await (
+				OrmUtils.mergeDeep(new Relationship(), { to_id: id, type: RelationshipType.blocked, from_id: req.user_id }) as Relationship
+			).save();
 		}
 
 		if (friendRequest && friendRequest.type !== RelationshipType.blocked) {
@@ -158,7 +164,12 @@ async function updateRelationship(req: Request, res: Response, friend: User, typ
 	const { maxFriends } = Config.get().limits.user;
 	if (user.relationships.length >= maxFriends) throw DiscordApiErrors.MAXIMUM_FRIENDS.withParams(maxFriends);
 
-	let incoming_relationship = OrmUtils.mergeDeep(new Relationship(), { nickname: undefined, type: RelationshipType.incoming, to: user, from: friend });
+	let incoming_relationship = OrmUtils.mergeDeep(new Relationship(), {
+		nickname: undefined,
+		type: RelationshipType.incoming,
+		to: user,
+		from: friend
+	});
 	let outgoing_relationship = OrmUtils.mergeDeep(new Relationship(), {
 		nickname: undefined,
 		type: RelationshipType.outgoing,