summary refs log tree commit diff
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/assets/openapi.json4
-rw-r--r--api/assets/schemas.json2
-rw-r--r--api/src/routes/guilds/#guild_id/members/#member_id/index.ts6
-rw-r--r--api/src/routes/users/@me/notes.ts6
4 files changed, 12 insertions, 6 deletions
diff --git a/api/assets/openapi.json b/api/assets/openapi.json
index 1af0600d..03550323 100644
--- a/api/assets/openapi.json
+++ b/api/assets/openapi.json
@@ -3119,7 +3119,7 @@
 						"type": "boolean"
 					},
 					"status": {
-						"enum": ["dnd", "idle", "offline", "online"],
+						"enum": ["dnd", "idle", "offline", "online", "invisible"],
 						"type": "string"
 					},
 					"stream_notifications_enabled": {
@@ -5677,7 +5677,7 @@
 						"type": "boolean"
 					},
 					"status": {
-						"enum": ["dnd", "idle", "offline", "online"],
+						"enum": ["dnd", "idle", "offline", "online", "invisible"],
 						"type": "string"
 					},
 					"stream_notifications_enabled": {
diff --git a/api/assets/schemas.json b/api/assets/schemas.json
index 4ffa44b8..d531df21 100644
--- a/api/assets/schemas.json
+++ b/api/assets/schemas.json
@@ -7897,7 +7897,7 @@
 				"type": "boolean"
 			},
 			"status": {
-				"enum": ["dnd", "idle", "offline", "online"],
+				"enum": ["dnd", "idle", "offline", "online", "invisible"],
 				"type": "string"
 			},
 			"stream_notifications_enabled": {
diff --git a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts
index 24c74af7..34836292 100644
--- a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts
@@ -25,13 +25,19 @@ router.patch("/", route({ body: "MemberChangeSchema" }), async (req: Request, re
 
 	const member = await Member.findOneOrFail({ where: { id: member_id, guild_id }, relations: ["roles", "user"] });
 	const permission = await getPermission(req.user_id, guild_id);
+	const everyone = await Role.findOneOrFail({ guild_id: guild_id, name: "@everyone", position: 0 });
 
 	if (body.roles) {
 		permission.hasThrow("MANAGE_ROLES");
+
+		if (body.roles.indexOf(everyone.id) === -1) body.roles.push(everyone.id);
 		member.roles = body.roles.map((x) => new Role({ id: x })); // foreign key constraint will fail if role doesn't exist
 	}
 
 	await member.save();
+
+	member.roles = member.roles.filter((x) => x.id !== everyone.id);
+
 	// do not use promise.all as we have to first write to db before emitting the event to catch errors
 	await emitEvent({
 		event: "GUILD_MEMBER_UPDATE",
diff --git a/api/src/routes/users/@me/notes.ts b/api/src/routes/users/@me/notes.ts
index 2ef27bc0..96067bf5 100644
--- a/api/src/routes/users/@me/notes.ts
+++ b/api/src/routes/users/@me/notes.ts
@@ -6,9 +6,9 @@ const router: Router = Router();
 router.put("/:id", route({}), async (req: Request, res: Response) => {
 	//TODO
 	res.json({
-		message: "400: Bad Request",
-		code: 0
-	}).status(400);
+		message: "Unknown User",
+		code: 10013
+	}).status(404);
 });
 
 export default router;