mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 05:02:37 +01:00
Merge branch 'master' of https://github.com/fosscord/fosscord-api
This commit is contained in:
commit
43a38ba46c
15
locales/hr/auth.json
Normal file
15
locales/hr/auth.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
18
locales/hr/common.json
Normal file
18
locales/hr/common.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
@ -13,11 +13,21 @@ import { emitEvent } from "./Event";
|
|||||||
|
|
||||||
// TODO: DM channel
|
// TODO: DM channel
|
||||||
export async function createChannel(channel: Partial<TextChannel | VoiceChannel>, user_id: string = "0") {
|
export async function createChannel(channel: Partial<TextChannel | VoiceChannel>, 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) {
|
switch (channel.type) {
|
||||||
case ChannelType.GUILD_TEXT:
|
case ChannelType.GUILD_TEXT:
|
||||||
case ChannelType.GUILD_VOICE:
|
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;
|
break;
|
||||||
case ChannelType.DM:
|
case ChannelType.DM:
|
||||||
case ChannelType.GROUP_DM:
|
case ChannelType.GROUP_DM:
|
||||||
@ -29,15 +39,7 @@ export async function createChannel(channel: Partial<TextChannel | VoiceChannel>
|
|||||||
throw new HTTPError("Not yet supported");
|
throw new HTTPError("Not yet supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
const permissions = await getPermission(user_id, channel.guild_id);
|
if (!channel.permission_overwrites) channel.permission_overwrites = [];
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: auto generate position
|
// TODO: auto generate position
|
||||||
|
|
||||||
channel = await new ChannelModel({
|
channel = await new ChannelModel({
|
||||||
|
Loading…
Reference in New Issue
Block a user