From b1d2d5127fb7eb681c030ef17a7f6565ce7bdeb6 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sun, 1 Aug 2021 10:54:28 +0200 Subject: [PATCH 1/3] New translations auth.json (Croatian) --- locales/hr/auth.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 locales/hr/auth.json diff --git a/locales/hr/auth.json b/locales/hr/auth.json new file mode 100644 index 00000000..3e330168 --- /dev/null +++ b/locales/hr/auth.json @@ -0,0 +1,15 @@ +{ + "login": { + "INVALID_LOGIN": "Email ili broj mobitela nije pronađen", + "INVALID_PASSWORD": "Pogrešna lozinka" + }, + "register": { + "REGISTRATION_DISABLED": "Registracija novog korisnika je onemogućena", + "INVITE_ONLY": "Morate biti pozvani da se registrirate", + "EMAIL_INVALID": "Nevažeći email", + "EMAIL_ALREADY_REGISTERED": "Email je već registriran", + "DATE_OF_BIRTH_UNDERAGE": "Morate imati {{years}} godina ili više", + "CONSENT_REQUIRED": "Morate se složiti s uvjetima pružanja usluge i pravila o privatnosti.", + "USERNAME_TOO_MANY_USERS": "Previše korisnika ima ovo korisničko ime, molimo vas da pokušate sa drugim" + } +} From 3adbf6d1dfadb48c8330de6c315fec6422b11b50 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sun, 1 Aug 2021 10:54:29 +0200 Subject: [PATCH 2/3] New translations common.json (Croatian) --- locales/hr/common.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 locales/hr/common.json diff --git a/locales/hr/common.json b/locales/hr/common.json new file mode 100644 index 00000000..2126f375 --- /dev/null +++ b/locales/hr/common.json @@ -0,0 +1,18 @@ +{ + "field": { + "BASE_TYPE_REQUIRED": "Ovo polje je obavezno", + "BASE_TYPE_STRING": "Ovo polje mora biti niz", + "BASE_TYPE_NUMBER": "Ovo polje mora biti broj", + "BASE_TYPE_BIGINT": "Ovo polje mora biti bigint", + "BASE_TYPE_BOOLEAN": "Ovo polje mora biti boolean", + "BASE_TYPE_CHOICES": "Ovo polje mora biti jedno od ({{types}})", + "BASE_TYPE_CLASS": "Ovo polje mora biti primjer od {{type}}", + "BASE_TYPE_OBJECT": "Ovo polje mora biti objekt", + "BASE_TYPE_ARRAY": "Ovo polje mora biti niz", + "UNKOWN_FIELD": "Nepoznati ključ: {{key}}", + "BASE_TYPE_CONSTANT": "Ovo polje mora biti {{value}}", + "EMAIL_TYPE_INVALID_EMAIL": "Nije dobro oblikovana Email adresa", + "DATE_TYPE_PARSE": "Nije moguće raščlaniti {{date}}. Treba biti ISO8601", + "BASE_TYPE_BAD_LENGTH": "Mora biti između {{length}} u duljini" + } +} \ No newline at end of file From 64220d51f9a8ad6f7a18d08e988cd9bd4700baea Mon Sep 17 00:00:00 2001 From: Paul Munteanu Date: Sun, 1 Aug 2021 21:01:56 +0300 Subject: [PATCH 3/3] [Channel] Implement type 4 channel and clean the code --- src/util/Channel.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/util/Channel.ts b/src/util/Channel.ts index 8dfc03bc..4d322812 100644 --- a/src/util/Channel.ts +++ b/src/util/Channel.ts @@ -13,11 +13,21 @@ import { emitEvent } from "./Event"; // TODO: DM channel export async function createChannel(channel: Partial, user_id: string = "0") { - if (!channel.permission_overwrites) channel.permission_overwrites = []; + + // Always check if user has permission first + const permissions = await getPermission(user_id, channel.guild_id); + permissions.hasThrow("MANAGE_CHANNELS"); switch (channel.type) { case ChannelType.GUILD_TEXT: case ChannelType.GUILD_VOICE: + if (channel.parent_id) { + const exists = await ChannelModel.findOne({ id: channel.parent_id }, { guild_id: true }).exec(); + if (!exists) throw new HTTPError("Parent id channel doesn't exist", 400); + if (exists.guild_id !== channel.guild_id) throw new HTTPError("The category channel needs to be in the guild"); + } + break; + case ChannelType.GUILD_CATEGORY: break; case ChannelType.DM: case ChannelType.GROUP_DM: @@ -29,15 +39,7 @@ export async function createChannel(channel: Partial throw new HTTPError("Not yet supported"); } - const permissions = await getPermission(user_id, channel.guild_id); - permissions.hasThrow("MANAGE_CHANNELS"); - - if (channel.parent_id) { - const exists = await ChannelModel.findOne({ id: channel.parent_id }, { guild_id: true }).exec(); - if (!exists) throw new HTTPError("Parent id channel doesn't exist", 400); - if (exists.guild_id !== channel.guild_id) throw new HTTPError("The category channel needs to be in the guild"); - } - + if (!channel.permission_overwrites) channel.permission_overwrites = []; // TODO: auto generate position channel = await new ChannelModel({