summary refs log tree commit diff
path: root/api
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-06-27 15:09:30 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-06-27 15:09:30 +1000
commit48d286d44ded115d5f726d399428c89f6063229c (patch)
tree5fbff9ba98faf0b1dcd1434917d9f13ec26dae12 /api
parentStart of custom login and discord oauth flow (diff)
parentMerge pull request #737 from fosscord/translation (diff)
downloadserver-48d286d44ded115d5f726d399428c89f6063229c.tar.xz
Merge branch 'master' into slowcord
Diffstat (limited to 'api')
-rw-r--r--api/locales/pl/auth.json4
-rw-r--r--api/locales/pl/common.json4
-rw-r--r--api/src/routes/guilds/#guild_id/members/#member_id/index.ts38
-rw-r--r--api/src/routes/invites/index.ts2
4 files changed, 34 insertions, 14 deletions
diff --git a/api/locales/pl/auth.json b/api/locales/pl/auth.json
index 3988e9cd..711cb4d7 100644
--- a/api/locales/pl/auth.json
+++ b/api/locales/pl/auth.json
@@ -1,13 +1,13 @@
 {
 	"login": {
-		"INVALID_LOGIN": "E-mail lub telefon nie został znaleziony",
+		"INVALID_LOGIN": "E-mail lub numer telefonu nie został znaleziony",
 		"INVALID_PASSWORD": "Nieprawidłowe hasło",
 		"ACCOUNT_DISABLED": "To konto jest nieaktywne"
 	},
 	"register": {
 		"REGISTRATION_DISABLED": "Rejestracja nowych użytkowników jest wyłączona",
 		"INVITE_ONLY": "Aby się zarejestrować, musisz zostać zaproszony",
-		"EMAIL_INVALID": "Nieprawidłowy email",
+		"EMAIL_INVALID": "Nieprawidłowy E-mail",
 		"EMAIL_ALREADY_REGISTERED": "E-mail jest już zarejestrowany",
 		"DATE_OF_BIRTH_UNDERAGE": "Musisz mieć {{years}} lat lub więcej",
 		"CONSENT_REQUIRED": "Musisz zaakceptować Regulamin i Politykę Prywatności.",
diff --git a/api/locales/pl/common.json b/api/locales/pl/common.json
index 3b618c1f..98c0906b 100644
--- a/api/locales/pl/common.json
+++ b/api/locales/pl/common.json
@@ -10,9 +10,9 @@
 		"BASE_TYPE_OBJECT": "To pole musi być obiektem",
 		"BASE_TYPE_ARRAY": "To pole musi być tablicą",
 		"UNKOWN_FIELD": "Nieznany klucz: {{key}}",
-		"BASE_TYPE_CONSTANT": "To pole musi być {{value}}",
+		"BASE_TYPE_CONSTANT": "To pole musi wynosić {{value}}",
 		"EMAIL_TYPE_INVALID_EMAIL": "Źle sformułowany adres e-mail",
 		"DATE_TYPE_PARSE": "Nie można przetworzyć {{date}}. Powinno być ISO8601",
-		"BASE_TYPE_BAD_LENGTH": "Długość musi wynosić między {{length}}"
+		"BASE_TYPE_BAD_LENGTH": "Długość musi wynosić pomiędzy {{length}}"
 	}
 }
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 34836292..c285abb3 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
@@ -1,5 +1,5 @@
 import { Request, Response, Router } from "express";
-import { Member, getPermission, Role, GuildMemberUpdateEvent, emitEvent, Sticker, Emoji, Guild } from "@fosscord/util";
+import { Member, getPermission, getRights, Role, GuildMemberUpdateEvent, emitEvent, Sticker, Emoji, Rights, Guild } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import { route } from "@fosscord/api";
 
@@ -52,27 +52,47 @@ router.put("/", route({}), async (req: Request, res: Response) => {
 
 	// TODO: Lurker mode
 
+	const rights = await getRights(req.user_id);
+
 	let { guild_id, member_id } = req.params;
-	if (member_id === "@me") member_id = req.user_id;
+	if (member_id === "@me") {
+		member_id = req.user_id;
+		rights.hasThrow("JOIN_GUILDS");
+	} else {
+		// TODO: join others by controller	
+	}
 
 	var guild = await Guild.findOneOrFail({
-		where: { id: guild_id }	});
+		where: { id: guild_id }
+	});
 
 	var emoji = await Emoji.find({
-		where: { guild_id: guild_id }	});
+		where: { guild_id: guild_id }
+	});
 
 	var roles = await Role.find({
-		where: { guild_id: guild_id }	});
+		where: { guild_id: guild_id }
+	});
 
 	var stickers = await Sticker.find({
-		where: { guild_id: guild_id }	});
-	
+		where: { guild_id: guild_id }
+	});
+
 	await Member.addToGuild(member_id, guild_id);
-	res.send({...guild, emojis: emoji, roles: roles, stickers: stickers});
+	res.send({ ...guild, emojis: emoji, roles: roles, stickers: stickers });
 });
 
-router.delete("/", route({ permission: "KICK_MEMBERS" }), async (req: Request, res: Response) => {
+router.delete("/", route({}), async (req: Request, res: Response) => {
+	const permission = await getPermission(req.user_id);
+	const rights = await getRights(req.user_id);
 	const { guild_id, member_id } = req.params;
+	if (member_id !== "@me" || member_id === req.user_id) {
+		// TODO: unless force-joined
+		rights.hasThrow("SELF_LEAVE_GROUPS");
+	} else {
+		rights.hasThrow("KICK_BAN_MEMBERS");
+		permission.hasThrow("KICK_MEMBERS");
+	}
 
 	await Member.removeFromGuild(member_id, guild_id);
 	res.sendStatus(204);
diff --git a/api/src/routes/invites/index.ts b/api/src/routes/invites/index.ts
index 21da2d18..eeafb22a 100644
--- a/api/src/routes/invites/index.ts
+++ b/api/src/routes/invites/index.ts
@@ -13,7 +13,7 @@ router.get("/:code", route({}), async (req: Request, res: Response) => {
 	res.status(200).send(invite);
 });
 
-router.post("/:code", route({right: "JOIN_GUILDS"}), async (req: Request, res: Response) => {
+router.post("/:code", route({right: "USE_MASS_INVITES"}), async (req: Request, res: Response) => {
 	const { code } = req.params;
     const { guild_id } = await Invite.findOneOrFail({ code })
 	const { features } = await Guild.findOneOrFail({ id: guild_id});