diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-06-27 15:09:30 +1000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-06-27 15:09:30 +1000 |
commit | 6fb88b99b5201ab835abfe2fbde01aa50b4cb00d (patch) | |
tree | 254e704dcd27952e27f4f69ffd804452e6fd58c9 | |
parent | Start of custom login and discord oauth flow (diff) | |
parent | Merge pull request #737 from fosscord/translation (diff) | |
download | server-6fb88b99b5201ab835abfe2fbde01aa50b4cb00d.tar.xz |
Merge branch 'master' into slowcord
-rw-r--r-- | api/locales/pl/auth.json | 4 | ||||
-rw-r--r-- | api/locales/pl/common.json | 4 | ||||
-rw-r--r-- | api/src/routes/guilds/#guild_id/members/#member_id/index.ts | 38 | ||||
-rw-r--r-- | api/src/routes/invites/index.ts | 2 | ||||
-rw-r--r-- | util/src/util/Rights.ts | 2 |
5 files changed, 36 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}); diff --git a/util/src/util/Rights.ts b/util/src/util/Rights.ts index 35ad9514..b28c75b7 100644 --- a/util/src/util/Rights.ts +++ b/util/src/util/Rights.ts @@ -71,6 +71,8 @@ export class Rights extends BitField { INITIATE_INTERACTIONS: BitFlag(40), // can initiate interactions RESPOND_TO_INTERACTIONS: BitFlag(41), // can respond to interactions SEND_BACKDATED_EVENTS: BitFlag(42), // can send backdated events + USE_MASS_INVITES: BitFlag(43), // added per @xnacly's request — can accept mass invites + ACCEPT_INVITES: BitFlag(44) // added per @xnacly's request — can accept user-specific invites and DM requests }; any(permission: RightResolvable, checkOperator = true) { |