summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-02-05 12:35:27 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-02-05 12:35:27 +1100
commitcc50ebf47b0cb4b19b68436037eff20d96874b3e (patch)
treea965b327906537454141a45ce6132a7d9d81d261 /src
parentDon't use relative path for db entities. Closes #937 (diff)
downloadserver-cc50ebf47b0cb4b19b68436037eff20d96874b3e.tar.xz
Fix being unable to unset nicknames
Remove unwanted guild profile handler in cdn
Fix rights check for bio/avatars of your own user
Diffstat (limited to 'src')
-rw-r--r--src/api/routes/guilds/#guild_id/members/#member_id/index.ts12
-rw-r--r--src/cdn/routes/guilds.ts28
2 files changed, 11 insertions, 29 deletions
diff --git a/src/api/routes/guilds/#guild_id/members/#member_id/index.ts b/src/api/routes/guilds/#guild_id/members/#member_id/index.ts
index d40f2772..6ac0dd3b 100644
--- a/src/api/routes/guilds/#guild_id/members/#member_id/index.ts
+++ b/src/api/routes/guilds/#guild_id/members/#member_id/index.ts
@@ -65,9 +65,19 @@ router.patch(
 
 		if ("nick" in body) {
 			permission.hasThrow("MANAGE_NICKNAMES");
+
+			if (!body.nick) {
+				delete body.nick;
+				// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+				//@ts-ignore shut up
+				member.nick = null; // remove the nickname
+			}
 		}
 
-		if (("bio" in body || "avatar" in body) && member_id != "@me") {
+		if (
+			("bio" in body || "avatar" in body) &&
+			req.params.member_id != "@me"
+		) {
 			const rights = await getRights(req.user_id);
 			rights.hasThrow("MANAGE_USERS");
 		}
diff --git a/src/cdn/routes/guilds.ts b/src/cdn/routes/guilds.ts
deleted file mode 100644
index e36fd363..00000000
--- a/src/cdn/routes/guilds.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-	Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
-	Copyright (C) 2023 Fosscord and Fosscord Contributors
-	
-	This program is free software: you can redistribute it and/or modify
-	it under the terms of the GNU Affero General Public License as published
-	by the Free Software Foundation, either version 3 of the License, or
-	(at your option) any later version.
-	
-	This program is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU Affero General Public License for more details.
-	
-	You should have received a copy of the GNU Affero General Public License
-	along with this program.  If not, see <https://www.gnu.org/licenses/>.
-*/
-
-import { Router } from "express";
-import { getAvatar } from "./avatars";
-
-const router = Router();
-
-// TODO: handle guild profiles
-router.get("/:guild_id/users/:user_id/avatars/:hash", getAvatar);
-router.get("/:guild_id/users/:user_id/banners/:hash", getAvatar);
-
-export default router;