diff --git a/api/src/routes/users/@me/index.ts b/api/src/routes/users/@me/index.ts
index 92499689..6a2456d6 100644
--- a/api/src/routes/users/@me/index.ts
+++ b/api/src/routes/users/@me/index.ts
@@ -32,9 +32,7 @@ router.patch("/", route({ body: "UserModifySchema" }), async (req: Request, res:
const body = req.body as UserModifySchema;
if (body.avatar) body.avatar = await handleFile(`/avatars/${req.user_id}`, body.avatar as string);
- if (body.banner) body.banner = await handleFile(`/banners/${req.user_id}`, body.banner as string);
-
- const user = await User.findOneOrFail({ where: { id: req.user_id }, select: [...PrivateUserProjection, "data"] });
+ if (body.banner) body.banner = await handleFile(`/banners/${req.user_id}`, body.banner as string);let user = await User.findOneOrFail({ where: { id: req.user_id }, select: [...PrivateUserProjection, "data"] });
if (body.password) {
if (user.data?.hash) {
@@ -65,7 +63,7 @@ router.patch("/", route({ body: "UserModifySchema" }), async (req: Request, res:
}
}
- user.assign(body);
+ user = Object.assign(user, body);
await user.save();
// @ts-ignore
diff --git a/api/src/routes/users/@me/relationships.ts b/api/src/routes/users/@me/relationships.ts
index 0509b0ac..014a5bd2 100644
--- a/api/src/routes/users/@me/relationships.ts
+++ b/api/src/routes/users/@me/relationships.ts
@@ -140,7 +140,7 @@ async function updateRelationship(req: Request, res: Response, friend: User, typ
relationship.type = RelationshipType.blocked;
await relationship.save();
} else {
- relationship = await new Relationship({ to_id: id, type: RelationshipType.blocked, from_id: req.user_id }).save();
+ relationship = await Object.assign(new Relationship(), { to_id: id, type: RelationshipType.blocked, from_id: req.user_id }).save();
}
if (friendRequest && friendRequest.type !== RelationshipType.blocked) {
@@ -166,8 +166,8 @@ 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 = new Relationship({ nickname: undefined, type: RelationshipType.incoming, to: user, from: friend });
- let outgoing_relationship = new Relationship({
+ let incoming_relationship = Object.assign(new Relationship(), { nickname: undefined, type: RelationshipType.incoming, to: user, from: friend });
+ let outgoing_relationship = Object.assign(new Relationship(), {
nickname: undefined,
type: RelationshipType.outgoing,
to: friend,
@@ -178,7 +178,7 @@ async function updateRelationship(req: Request, res: Response, friend: User, typ
if (friendRequest.type === RelationshipType.blocked) throw new HTTPError("The user blocked you");
if (friendRequest.type === RelationshipType.friends) throw new HTTPError("You are already friends with the user");
// accept friend request
- incoming_relationship = friendRequest;
+ incoming_relationship = friendRequest as any; //TODO: checkme, any cast
incoming_relationship.type = RelationshipType.friends;
}
@@ -186,7 +186,7 @@ async function updateRelationship(req: Request, res: Response, friend: User, typ
if (relationship.type === RelationshipType.outgoing) throw new HTTPError("You already sent a friend request");
if (relationship.type === RelationshipType.blocked) throw new HTTPError("Unblock the user before sending a friend request");
if (relationship.type === RelationshipType.friends) throw new HTTPError("You are already friends with the user");
- outgoing_relationship = relationship;
+ outgoing_relationship = relationship as any; //TODO: checkme, any cast
outgoing_relationship.type = RelationshipType.friends;
}
|