mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-25 19:52:36 +01:00
Merge branch 'master' into slowcord
This commit is contained in:
commit
48d286d44d
@ -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.",
|
||||
|
@ -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}}"
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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});
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user