From e31d8e85a62114e275cb495d0378109542824033 Mon Sep 17 00:00:00 2001 From: Daniel Huber <30466471+daniel0611@users.noreply.github.com> Date: Mon, 3 Jan 2022 11:02:42 +0100 Subject: Incrementing user discriminators Closes #328 --- util/src/entities/Config.ts | 2 ++ util/src/entities/User.ts | 49 ++++++++++++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 16 deletions(-) (limited to 'util/src') diff --git a/util/src/entities/Config.ts b/util/src/entities/Config.ts index 9e25c737..6993cc09 100644 --- a/util/src/entities/Config.ts +++ b/util/src/entities/Config.ts @@ -149,6 +149,7 @@ export interface ConfigValue { minUpperCase: number; minSymbols: number; }; + incrementingDiscriminators: boolean; // random otherwise }; regions: { default: string; @@ -335,6 +336,7 @@ export const DefaultConfigOptions: ConfigValue = { minUpperCase: 2, minSymbols: 0, }, + incrementingDiscriminators: false, }, regions: { default: "fosscord", diff --git a/util/src/entities/User.ts b/util/src/entities/User.ts index bc852616..5f2618e0 100644 --- a/util/src/entities/User.ts +++ b/util/src/entities/User.ts @@ -64,7 +64,7 @@ export class User extends BaseClass { setDiscriminator(val: string) { const number = Number(val); if (isNaN(number)) throw new Error("invalid discriminator"); - if (number <= 0 || number > 10000) throw new Error("discriminator must be between 1 and 9999"); + if (number <= 0 || number >= 10000) throw new Error("discriminator must be between 1 and 9999"); this.discriminator = val.toString().padStart(4, "0"); } @@ -178,6 +178,35 @@ export class User extends BaseClass { ); } + private static async generateDiscriminator(username: string): Promise { + if (Config.get().register.incrementingDiscriminators) { + // discriminator will be incrementally generated + + // First we need to figure out the currently highest discrimnator for the given username and then increment it + const users = await User.find({ where: { username }, select: ["discriminator"] }); + const highestDiscriminator = Math.max(0, ...users.map((u) => Number(u.discriminator))); + + const discriminator = highestDiscriminator + 1; + if (discriminator >= 10000) { + return undefined; + } + + return discriminator.toString().padStart(4, "0"); + } else { + // discriminator will be randomly generated + + // randomly generates a discriminator between 1 and 9999 and checks max five times if it already exists + // TODO: is there any better way to generate a random discriminator only once, without checking if it already exists in the database? + for (let tries = 0; tries < 5; tries++) { + const discriminator = Math.randomIntBetween(1, 9999).toString().padStart(4, "0"); + const exists = await User.findOne({ where: { discriminator, username: username }, select: ["id"] }); + if (!exists) return discriminator; + } + + return undefined; + } + } + static async register({ email, username, @@ -194,21 +223,9 @@ export class User extends BaseClass { // trim special uf8 control characters -> Backspace, Newline, ... username = trimSpecial(username); - // discriminator will be randomly generated - let discriminator = ""; - - let exists; - // randomly generates a discriminator between 1 and 9999 and checks max five times if it already exists - // if it all five times already exists, abort with USERNAME_TOO_MANY_USERS error - // else just continue - // TODO: is there any better way to generate a random discriminator only once, without checking if it already exists in the database? - for (let tries = 0; tries < 5; tries++) { - discriminator = Math.randomIntBetween(1, 9999).toString().padStart(4, "0"); - exists = await User.findOne({ where: { discriminator, username: username }, select: ["id"] }); - if (!exists) break; - } - - if (exists) { + const discriminator = await User.generateDiscriminator(username); + if (!discriminator) { + // We've failed to generate a valid and unused discriminator throw FieldErrors({ username: { code: "USERNAME_TOO_MANY_USERS", -- cgit 1.5.1 From aaf5df14e1523ef70fcb9aa5ff9fc0b73ff42fee Mon Sep 17 00:00:00 2001 From: Chris Chrome Date: Wed, 5 Jan 2022 05:44:14 -0500 Subject: Add Role Icons (#574) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Role Icons Co-authored-by: Erkin Alp Güney * Cache coherency rules Co-authored-by: MANIKILLER Co-authored-by: ImAaronFR <96433859+ImAaronFR@users.noreply.github.com> --- api/src/routes/guilds/#guild_id/roles.ts | 11 +++- bundle/package.json | 2 +- cdn/src/Server.ts | 4 ++ cdn/src/routes/role-icons.ts | 102 +++++++++++++++++++++++++++++++ util/src/entities/Guild.ts | 2 + util/src/entities/Role.ts | 6 ++ 6 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 cdn/src/routes/role-icons.ts (limited to 'util/src') diff --git a/api/src/routes/guilds/#guild_id/roles.ts b/api/src/routes/guilds/#guild_id/roles.ts index b1875598..b6894e3f 100644 --- a/api/src/routes/guilds/#guild_id/roles.ts +++ b/api/src/routes/guilds/#guild_id/roles.ts @@ -8,7 +8,8 @@ import { GuildRoleDeleteEvent, emitEvent, Config, - DiscordApiErrors + DiscordApiErrors, + handleFile } from "@fosscord/util"; import { HTTPError } from "lambert-server"; import { route } from "@fosscord/api"; @@ -22,6 +23,8 @@ export interface RoleModifySchema { hoist?: boolean; // whether the role should be displayed separately in the sidebar mentionable?: boolean; // whether the role should be mentionable position?: number; + icon?: string; + unicode_emoji?: string; } export type RolePositionUpdateSchema = { @@ -58,7 +61,9 @@ router.post("/", route({ body: "RoleModifySchema", permission: "MANAGE_ROLES" }) guild_id: guild_id, managed: false, permissions: String(req.permission!.bitfield & BigInt(body.permissions || "0")), - tags: undefined + tags: undefined, + icon: null, + unicode_emoji: null }); await Promise.all([ @@ -105,6 +110,8 @@ router.patch("/:role_id", route({ body: "RoleModifySchema", permission: "MANAGE_ const { role_id, guild_id } = req.params; const body = req.body as RoleModifySchema; + if (body.icon) body.icon = await handleFile(`/role-icons/${role_id}`, body.icon as string); + const role = new Role({ ...body, id: role_id, diff --git a/bundle/package.json b/bundle/package.json index e0ae6156..456c89d7 100644 --- a/bundle/package.json +++ b/bundle/package.json @@ -107,4 +107,4 @@ "ws": "^7.4.2", "nanocolors": "^0.2.12" } -} \ No newline at end of file +} diff --git a/cdn/src/Server.ts b/cdn/src/Server.ts index cac34a80..b8d71fa9 100644 --- a/cdn/src/Server.ts +++ b/cdn/src/Server.ts @@ -2,6 +2,7 @@ import { Server, ServerOptions } from "lambert-server"; import { Config, initDatabase, registerRoutes } from "@fosscord/util"; import path from "path"; import avatarsRoute from "./routes/avatars"; +import iconsRoute from "./routes/role-icons"; import bodyParser from "body-parser"; export interface CDNServerOptions extends ServerOptions {} @@ -40,6 +41,9 @@ export class CDNServer extends Server { this.app.use("/icons/", avatarsRoute); this.log("verbose", "[Server] Route /icons registered"); + this.app.use("/role-icons/", iconsRoute); + this.log("verbose", "[Server] Route /role-icons registered"); + this.app.use("/emojis/", avatarsRoute); this.log("verbose", "[Server] Route /emojis registered"); diff --git a/cdn/src/routes/role-icons.ts b/cdn/src/routes/role-icons.ts new file mode 100644 index 00000000..1ad1637d --- /dev/null +++ b/cdn/src/routes/role-icons.ts @@ -0,0 +1,102 @@ +import { Router, Response, Request } from "express"; +import { Config, Snowflake } from "@fosscord/util"; +import { storage } from "../util/Storage"; +import FileType from "file-type"; +import { HTTPError } from "lambert-server"; +import crypto from "crypto"; +import { multer } from "../util/multer"; + +//Role icons ---> avatars.ts modified + +// TODO: check premium and animated pfp are allowed in the config +// TODO: generate different sizes of icon +// TODO: generate different image types of icon +// TODO: delete old icons + +const STATIC_MIME_TYPES = [ + "image/png", + "image/jpeg", + "image/webp", + "image/svg+xml", + "image/svg", +]; +const ALLOWED_MIME_TYPES = [...STATIC_MIME_TYPES]; + +const router = Router(); + +router.post( + "/:role_id", + multer.single("file"), + async (req: Request, res: Response) => { + if (req.headers.signature !== Config.get().security.requestSignature) + throw new HTTPError("Invalid request signature"); + if (!req.file) throw new HTTPError("Missing file"); + const { buffer, mimetype, size, originalname, fieldname } = req.file; + const { role_id } = req.params; + + var hash = crypto + .createHash("md5") + .update(Snowflake.generate()) + .digest("hex"); + + const type = await FileType.fromBuffer(buffer); + if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) + throw new HTTPError("Invalid file type"); + + const path = `role-icons/${role_id}/${hash}.png`; + const endpoint = + Config.get().cdn.endpointPublic || "http://localhost:3003"; + + await storage.set(path, buffer); + + return res.json({ + id: hash, + content_type: type.mime, + size, + url: `${endpoint}${req.baseUrl}/${role_id}/${hash}`, + }); + } +); + +router.get("/:role_id", async (req: Request, res: Response) => { + var { role_id } = req.params; + //role_id = role_id.split(".")[0]; // remove .file extension + const path = `role-icons/${role_id}`; + + const file = await storage.get(path); + if (!file) throw new HTTPError("not found", 404); + const type = await FileType.fromBuffer(file); + + res.set("Content-Type", type?.mime); + res.set("Cache-Control", "public, max-age=31536000, must-revalidate"); + + return res.send(file); +}); + +router.get("/:role_id/:hash", async (req: Request, res: Response) => { + var { role_id, hash } = req.params; + //hash = hash.split(".")[0]; // remove .file extension + const path = `role-icons/${role_id}/${hash}`; + + const file = await storage.get(path); + if (!file) throw new HTTPError("not found", 404); + const type = await FileType.fromBuffer(file); + + res.set("Content-Type", type?.mime); + res.set("Cache-Control", "public, max-age=31536000, must-revalidate"); + + return res.send(file); +}); + +router.delete("/:role_id/:id", async (req: Request, res: Response) => { + if (req.headers.signature !== Config.get().security.requestSignature) + throw new HTTPError("Invalid request signature"); + const { role_id, id } = req.params; + const path = `role-icons/${role_id}/${id}`; + + await storage.delete(path); + + return res.send({ success: true }); +}); + +export default router; diff --git a/util/src/entities/Guild.ts b/util/src/entities/Guild.ts index 157f0921..f4c94a64 100644 --- a/util/src/entities/Guild.ts +++ b/util/src/entities/Guild.ts @@ -340,6 +340,8 @@ export class Guild extends BaseClass { name: "@everyone", permissions: String("2251804225"), position: 0, + icon: null, + unicode_emoji: null }).save(); if (!body.channels || !body.channels.length) body.channels = [{ id: "01", type: 0, name: "general" }]; diff --git a/util/src/entities/Role.ts b/util/src/entities/Role.ts index 9fca99a5..4b721b5b 100644 --- a/util/src/entities/Role.ts +++ b/util/src/entities/Role.ts @@ -36,6 +36,12 @@ export class Role extends BaseClass { @Column() position: number; + @Column({ nullable: true }) + icon: string; + + @Column({ nullable: true }) + unicode_emoji: string; + @Column({ type: "simple-json", nullable: true }) tags?: { bot_id?: string; -- cgit 1.5.1 From 90ba897ca4283d549208df1efa56795f1d133843 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Wed, 12 Jan 2022 09:55:14 +0300 Subject: Schema change for group specific emojis --- util/src/entities/Emoji.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/entities/Emoji.ts b/util/src/entities/Emoji.ts index 03218375..32d39234 100644 --- a/util/src/entities/Emoji.ts +++ b/util/src/entities/Emoji.ts @@ -10,7 +10,7 @@ export class Emoji extends BaseClass { animated: boolean; @Column() - available: boolean; // whether this emoji can be used, may be false due to loss of Server Boosts + available: boolean; // whether this emoji can be used, may be false due to various reasons @Column() guild_id: string; @@ -40,4 +40,7 @@ export class Emoji extends BaseClass { @Column({ type: "simple-array" }) roles: string[]; // roles this emoji is whitelisted to (new discord feature?) + + @Column({ type: "simple-array" }) + groups: string[]; // user groups this emoji is whitelisted to (Fosscord extension) } -- cgit 1.5.1 From 26781e736c5877d31f7a1fbde3bebe188caa008a Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Wed, 12 Jan 2022 10:19:05 +0300 Subject: Update Guild.ts --- util/src/entities/Guild.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'util/src') diff --git a/util/src/entities/Guild.ts b/util/src/entities/Guild.ts index f4c94a64..00f92679 100644 --- a/util/src/entities/Guild.ts +++ b/util/src/entities/Guild.ts @@ -330,6 +330,7 @@ export class Guild extends BaseClass { }).save(); // we have to create the role _after_ the guild because else we would get a "SQLITE_CONSTRAINT: FOREIGN KEY constraint failed" error + // TODO: make the @everyone a pseudorole that is dynamically generated at runtime so we can save storage await new Role({ id: guild_id, guild_id: guild_id, -- cgit 1.5.1 From cc698225a0e6cab61363b3585bbab30d022c0207 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Wed, 12 Jan 2022 16:13:13 +0300 Subject: update defaults --- util/src/entities/Guild.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'util/src') diff --git a/util/src/entities/Guild.ts b/util/src/entities/Guild.ts index 00f92679..6a1df4d6 100644 --- a/util/src/entities/Guild.ts +++ b/util/src/entities/Guild.ts @@ -213,7 +213,7 @@ export class Guild extends BaseClass { owner: User; @Column({ nullable: true }) - preferred_locale?: string; // only community guilds can choose this + preferred_locale?: string; @Column({ nullable: true }) premium_subscription_count?: number; @@ -301,22 +301,22 @@ export class Guild extends BaseClass { name: body.name || "Fosscord", icon: await handleFile(`/icons/${guild_id}`, body.icon as string), region: Config.get().regions.default, - owner_id: body.owner_id, + owner_id: body.owner_id, // TODO: need to figure out a way for ownerless guilds and multiply-owned guilds afk_timeout: 300, - default_message_notifications: 0, + default_message_notifications: 1, // defaults effect: setting the push default at mentions-only will save a lot explicit_content_filter: 0, features: [], id: guild_id, max_members: 250000, max_presences: 250000, - max_video_channel_users: 25, + max_video_channel_users: 200, presence_count: 0, member_count: 0, // will automatically be increased by addMember() mfa_level: 0, preferred_locale: "en-US", premium_subscription_count: 0, premium_tier: 0, - system_channel_flags: 0, + system_channel_flags: 4, // defaults effect: suppress the setup tips to save performance unavailable: false, nsfw: false, nsfw_level: 0, @@ -326,7 +326,7 @@ export class Guild extends BaseClass { description: "No description", welcome_channels: [], }, - widget_enabled: false, + widget_enabled: true, // NB: don't set it as false to prevent artificial restrictions }).save(); // we have to create the role _after_ the guild because else we would get a "SQLITE_CONSTRAINT: FOREIGN KEY constraint failed" error @@ -337,6 +337,7 @@ export class Guild extends BaseClass { color: 0, hoist: false, managed: false, + // NB: in Fosscord, every role will be non-managed, as we use user-groups instead of roles for managed groups mentionable: false, name: "@everyone", permissions: String("2251804225"), @@ -358,7 +359,6 @@ export class Guild extends BaseClass { for (const channel of body.channels?.sort((a, b) => (a.parent_id ? 1 : -1))) { var id = ids.get(channel.id) || Snowflake.generate(); - // TODO: should we abort if parent_id is a category? (to disallow sub category channels) var parent_id = ids.get(channel.parent_id); await Channel.createChannel({ ...channel, guild_id, id, parent_id }, body.owner_id, { -- cgit 1.5.1 From 35c7489f72feb3c432d67e2d6d1d0ef8c70c08a4 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Fri, 14 Jan 2022 01:20:26 +1100 Subject: Added `ILLEGAL_CHANNEL_NAMES` and `NULL_CHANNEL_NAMES` guild feature flags --- util/src/entities/Channel.ts | 682 ++++++++++++++++++----------------- util/src/util/InvisibleCharacters.ts | 55 +++ util/src/util/index.ts | 1 + 3 files changed, 406 insertions(+), 332 deletions(-) create mode 100644 util/src/util/InvisibleCharacters.ts (limited to 'util/src') diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts index 4036b5d6..e7e0bace 100644 --- a/util/src/entities/Channel.ts +++ b/util/src/entities/Channel.ts @@ -1,332 +1,350 @@ -import { Column, Entity, JoinColumn, ManyToOne, OneToMany, RelationId } from "typeorm"; -import { BaseClass } from "./BaseClass"; -import { Guild } from "./Guild"; -import { PublicUserProjection, User } from "./User"; -import { HTTPError } from "lambert-server"; -import { containsAll, emitEvent, getPermission, Snowflake, trimSpecial } from "../util"; -import { ChannelCreateEvent, ChannelRecipientRemoveEvent } from "../interfaces"; -import { Recipient } from "./Recipient"; -import { Message } from "./Message"; -import { ReadState } from "./ReadState"; -import { Invite } from "./Invite"; -import { VoiceState } from "./VoiceState"; -import { Webhook } from "./Webhook"; -import { DmChannelDTO } from "../dtos"; - -export enum ChannelType { - GUILD_TEXT = 0, // a text channel within a server - DM = 1, // a direct message between users - GUILD_VOICE = 2, // a voice channel within a server - GROUP_DM = 3, // a direct message between multiple users - GUILD_CATEGORY = 4, // an organizational category that contains up to 50 channels - GUILD_NEWS = 5, // a channel that users can follow and crosspost into their own server - GUILD_STORE = 6, // a channel in which game developers can sell their game on Discord - // TODO: what are channel types between 7-9? - GUILD_NEWS_THREAD = 10, // a temporary sub-channel within a GUILD_NEWS channel - GUILD_PUBLIC_THREAD = 11, // a temporary sub-channel within a GUILD_TEXT channel - GUILD_PRIVATE_THREAD = 12, // a temporary sub-channel within a GUILD_TEXT channel that is only viewable by those invited and those with the MANAGE_THREADS permission - GUILD_STAGE_VOICE = 13, // a voice channel for hosting events with an audience -} - -@Entity("channels") -export class Channel extends BaseClass { - @Column() - created_at: Date; - - @Column({ nullable: true }) - name?: string; - - @Column({ type: "text", nullable: true }) - icon?: string | null; - - @Column({ type: "int" }) - type: ChannelType; - - @OneToMany(() => Recipient, (recipient: Recipient) => recipient.channel, { - cascade: true, - orphanedRowAction: "delete", - }) - recipients?: Recipient[]; - - @Column({ nullable: true }) - last_message_id: string; - - @Column({ nullable: true }) - @RelationId((channel: Channel) => channel.guild) - guild_id?: string; - - @JoinColumn({ name: "guild_id" }) - @ManyToOne(() => Guild, { - onDelete: "CASCADE", - }) - guild: Guild; - - @Column({ nullable: true }) - @RelationId((channel: Channel) => channel.parent) - parent_id: string; - - @JoinColumn({ name: "parent_id" }) - @ManyToOne(() => Channel) - parent?: Channel; - - // only for group dms - @Column({ nullable: true }) - @RelationId((channel: Channel) => channel.owner) - owner_id: string; - - @JoinColumn({ name: "owner_id" }) - @ManyToOne(() => User) - owner: User; - - @Column({ nullable: true }) - last_pin_timestamp?: number; - - @Column({ nullable: true }) - default_auto_archive_duration?: number; - - @Column({ nullable: true }) - position?: number; - - @Column({ type: "simple-json", nullable: true }) - permission_overwrites?: ChannelPermissionOverwrite[]; - - @Column({ nullable: true }) - video_quality_mode?: number; - - @Column({ nullable: true }) - bitrate?: number; - - @Column({ nullable: true }) - user_limit?: number; - - @Column({ nullable: true }) - nsfw?: boolean; - - @Column({ nullable: true }) - rate_limit_per_user?: number; - - @Column({ nullable: true }) - topic?: string; - - @OneToMany(() => Invite, (invite: Invite) => invite.channel, { - cascade: true, - orphanedRowAction: "delete", - }) - invites?: Invite[]; - - @OneToMany(() => Message, (message: Message) => message.channel, { - cascade: true, - orphanedRowAction: "delete", - }) - messages?: Message[]; - - @OneToMany(() => VoiceState, (voice_state: VoiceState) => voice_state.channel, { - cascade: true, - orphanedRowAction: "delete", - }) - voice_states?: VoiceState[]; - - @OneToMany(() => ReadState, (read_state: ReadState) => read_state.channel, { - cascade: true, - orphanedRowAction: "delete", - }) - read_states?: ReadState[]; - - @OneToMany(() => Webhook, (webhook: Webhook) => webhook.channel, { - cascade: true, - orphanedRowAction: "delete", - }) - webhooks?: Webhook[]; - - // TODO: DM channel - static async createChannel( - channel: Partial, - user_id: string = "0", - opts?: { - keepId?: boolean; - skipExistsCheck?: boolean; - skipPermissionCheck?: boolean; - skipEventEmit?: boolean; - } - ) { - if (!opts?.skipPermissionCheck) { - // 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 && !opts?.skipExistsCheck) { - const exists = await Channel.findOneOrFail({ id: channel.parent_id }); - 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: - throw new HTTPError("You can't create a dm channel in a guild"); - // TODO: check if guild is community server - case ChannelType.GUILD_STORE: - case ChannelType.GUILD_NEWS: - default: - throw new HTTPError("Not yet supported"); - } - - if (!channel.permission_overwrites) channel.permission_overwrites = []; - // TODO: auto generate position - - channel = { - ...channel, - ...(!opts?.keepId && { id: Snowflake.generate() }), - created_at: new Date(), - position: channel.position || 0, - }; - - await Promise.all([ - new Channel(channel).save(), - !opts?.skipEventEmit - ? emitEvent({ - event: "CHANNEL_CREATE", - data: channel, - guild_id: channel.guild_id, - } as ChannelCreateEvent) - : Promise.resolve(), - ]); - - return channel; - } - - static async createDMChannel(recipients: string[], creator_user_id: string, name?: string) { - recipients = recipients.unique().filter((x) => x !== creator_user_id); - const otherRecipientsUsers = await User.find({ where: recipients.map((x) => ({ id: x })) }); - - // TODO: check config for max number of recipients - if (otherRecipientsUsers.length !== recipients.length) { - throw new HTTPError("Recipient/s not found"); - } - - const type = recipients.length === 1 ? ChannelType.DM : ChannelType.GROUP_DM; - - let channel = null; - - const channelRecipients = [...recipients, creator_user_id]; - - const userRecipients = await Recipient.find({ - where: { user_id: creator_user_id }, - relations: ["channel", "channel.recipients"], - }); - - for (let ur of userRecipients) { - let re = ur.channel.recipients!.map((r) => r.user_id); - if (re.length === channelRecipients.length) { - if (containsAll(re, channelRecipients)) { - if (channel == null) { - channel = ur.channel; - await ur.assign({ closed: false }).save(); - } - } - } - } - - if (channel == null) { - name = trimSpecial(name); - - channel = await new Channel({ - name, - type, - owner_id: type === ChannelType.DM ? undefined : creator_user_id, - created_at: new Date(), - last_message_id: null, - recipients: channelRecipients.map( - (x) => - new Recipient({ user_id: x, closed: !(type === ChannelType.GROUP_DM || x === creator_user_id) }) - ), - }).save(); - } - - const channel_dto = await DmChannelDTO.from(channel); - - if (type === ChannelType.GROUP_DM) { - for (let recipient of channel.recipients!) { - await emitEvent({ - event: "CHANNEL_CREATE", - data: channel_dto.excludedRecipients([recipient.user_id]), - user_id: recipient.user_id, - }); - } - } else { - await emitEvent({ event: "CHANNEL_CREATE", data: channel_dto, user_id: creator_user_id }); - } - - return channel_dto.excludedRecipients([creator_user_id]); - } - - static async removeRecipientFromChannel(channel: Channel, user_id: string) { - await Recipient.delete({ channel_id: channel.id, user_id: user_id }); - channel.recipients = channel.recipients?.filter((r) => r.user_id !== user_id); - - if (channel.recipients?.length === 0) { - await Channel.deleteChannel(channel); - await emitEvent({ - event: "CHANNEL_DELETE", - data: await DmChannelDTO.from(channel, [user_id]), - user_id: user_id, - }); - return; - } - - await emitEvent({ - event: "CHANNEL_DELETE", - data: await DmChannelDTO.from(channel, [user_id]), - user_id: user_id, - }); - - //If the owner leave we make the first recipient in the list the new owner - if (channel.owner_id === user_id) { - channel.owner_id = channel.recipients!.find((r) => r.user_id !== user_id)!.user_id; //Is there a criteria to choose the new owner? - await emitEvent({ - event: "CHANNEL_UPDATE", - data: await DmChannelDTO.from(channel, [user_id]), - channel_id: channel.id, - }); - } - - await channel.save(); - - await emitEvent({ - event: "CHANNEL_RECIPIENT_REMOVE", - data: { - channel_id: channel.id, - user: await User.findOneOrFail({ where: { id: user_id }, select: PublicUserProjection }), - }, - channel_id: channel.id, - } as ChannelRecipientRemoveEvent); - } - - static async deleteChannel(channel: Channel) { - await Message.delete({ channel_id: channel.id }); //TODO we should also delete the attachments from the cdn but to do that we need to move cdn.ts in util - //TODO before deleting the channel we should check and delete other relations - await Channel.delete({ id: channel.id }); - } - - isDm() { - return this.type === ChannelType.DM || this.type === ChannelType.GROUP_DM; - } -} - -export interface ChannelPermissionOverwrite { - allow: string; - deny: string; - id: string; - type: ChannelPermissionOverwriteType; -} - -export enum ChannelPermissionOverwriteType { - role = 0, - member = 1, -} +import { Column, Entity, JoinColumn, ManyToOne, OneToMany, RelationId } from "typeorm"; +import { BaseClass } from "./BaseClass"; +import { Guild } from "./Guild"; +import { PublicUserProjection, User } from "./User"; +import { HTTPError } from "lambert-server"; +import { containsAll, emitEvent, getPermission, Snowflake, trimSpecial, InvisibleCharacters } from "../util"; +import { ChannelCreateEvent, ChannelRecipientRemoveEvent } from "../interfaces"; +import { Recipient } from "./Recipient"; +import { Message } from "./Message"; +import { ReadState } from "./ReadState"; +import { Invite } from "./Invite"; +import { VoiceState } from "./VoiceState"; +import { Webhook } from "./Webhook"; +import { DmChannelDTO } from "../dtos"; + +export enum ChannelType { + GUILD_TEXT = 0, // a text channel within a server + DM = 1, // a direct message between users + GUILD_VOICE = 2, // a voice channel within a server + GROUP_DM = 3, // a direct message between multiple users + GUILD_CATEGORY = 4, // an organizational category that contains up to 50 channels + GUILD_NEWS = 5, // a channel that users can follow and crosspost into their own server + GUILD_STORE = 6, // a channel in which game developers can sell their game on Discord + // TODO: what are channel types between 7-9? + GUILD_NEWS_THREAD = 10, // a temporary sub-channel within a GUILD_NEWS channel + GUILD_PUBLIC_THREAD = 11, // a temporary sub-channel within a GUILD_TEXT channel + GUILD_PRIVATE_THREAD = 12, // a temporary sub-channel within a GUILD_TEXT channel that is only viewable by those invited and those with the MANAGE_THREADS permission + GUILD_STAGE_VOICE = 13, // a voice channel for hosting events with an audience +} + +@Entity("channels") +export class Channel extends BaseClass { + @Column() + created_at: Date; + + @Column({ nullable: true }) + name?: string; + + @Column({ type: "text", nullable: true }) + icon?: string | null; + + @Column({ type: "int" }) + type: ChannelType; + + @OneToMany(() => Recipient, (recipient: Recipient) => recipient.channel, { + cascade: true, + orphanedRowAction: "delete", + }) + recipients?: Recipient[]; + + @Column({ nullable: true }) + last_message_id: string; + + @Column({ nullable: true }) + @RelationId((channel: Channel) => channel.guild) + guild_id?: string; + + @JoinColumn({ name: "guild_id" }) + @ManyToOne(() => Guild, { + onDelete: "CASCADE", + }) + guild: Guild; + + @Column({ nullable: true }) + @RelationId((channel: Channel) => channel.parent) + parent_id: string; + + @JoinColumn({ name: "parent_id" }) + @ManyToOne(() => Channel) + parent?: Channel; + + // only for group dms + @Column({ nullable: true }) + @RelationId((channel: Channel) => channel.owner) + owner_id: string; + + @JoinColumn({ name: "owner_id" }) + @ManyToOne(() => User) + owner: User; + + @Column({ nullable: true }) + last_pin_timestamp?: number; + + @Column({ nullable: true }) + default_auto_archive_duration?: number; + + @Column({ nullable: true }) + position?: number; + + @Column({ type: "simple-json", nullable: true }) + permission_overwrites?: ChannelPermissionOverwrite[]; + + @Column({ nullable: true }) + video_quality_mode?: number; + + @Column({ nullable: true }) + bitrate?: number; + + @Column({ nullable: true }) + user_limit?: number; + + @Column({ nullable: true }) + nsfw?: boolean; + + @Column({ nullable: true }) + rate_limit_per_user?: number; + + @Column({ nullable: true }) + topic?: string; + + @OneToMany(() => Invite, (invite: Invite) => invite.channel, { + cascade: true, + orphanedRowAction: "delete", + }) + invites?: Invite[]; + + @OneToMany(() => Message, (message: Message) => message.channel, { + cascade: true, + orphanedRowAction: "delete", + }) + messages?: Message[]; + + @OneToMany(() => VoiceState, (voice_state: VoiceState) => voice_state.channel, { + cascade: true, + orphanedRowAction: "delete", + }) + voice_states?: VoiceState[]; + + @OneToMany(() => ReadState, (read_state: ReadState) => read_state.channel, { + cascade: true, + orphanedRowAction: "delete", + }) + read_states?: ReadState[]; + + @OneToMany(() => Webhook, (webhook: Webhook) => webhook.channel, { + cascade: true, + orphanedRowAction: "delete", + }) + webhooks?: Webhook[]; + + // TODO: DM channel + static async createChannel( + channel: Partial, + user_id: string = "0", + opts?: { + keepId?: boolean; + skipExistsCheck?: boolean; + skipPermissionCheck?: boolean; + skipEventEmit?: boolean; + skipNameChecks?: boolean; + } + ) { + if (!opts?.skipPermissionCheck) { + // Always check if user has permission first + const permissions = await getPermission(user_id, channel.guild_id); + permissions.hasThrow("MANAGE_CHANNELS"); + } + + if (!opts?.skipNameChecks) { + const guild = await Guild.findOneOrFail({ id: channel.guild_id }); + if (!guild.features.includes("ILLEGAL_CHANNEL_NAMES") && channel.name) { + for (var character of InvisibleCharacters) + channel.name = channel.name.split(character).join("-"); + + channel.name = channel.name.split(/\-+/g).join("-"); //replace multiple occurances with just one + channel.name = channel.name.split("-").filter(Boolean).join("-"); //trim '-' character + } + + if (!guild.features.includes("NULL_CHANNEL_NAMES")) { + if (channel.name) channel.name = channel.name.trim(); + + if (!channel.name) throw new HTTPError("Channel name cannot be empty."); + } + } + + switch (channel.type) { + case ChannelType.GUILD_TEXT: + case ChannelType.GUILD_VOICE: + if (channel.parent_id && !opts?.skipExistsCheck) { + const exists = await Channel.findOneOrFail({ id: channel.parent_id }); + 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: + throw new HTTPError("You can't create a dm channel in a guild"); + // TODO: check if guild is community server + case ChannelType.GUILD_STORE: + case ChannelType.GUILD_NEWS: + default: + throw new HTTPError("Not yet supported"); + } + + if (!channel.permission_overwrites) channel.permission_overwrites = []; + // TODO: auto generate position + + channel = { + ...channel, + ...(!opts?.keepId && { id: Snowflake.generate() }), + created_at: new Date(), + position: channel.position || 0, + }; + + await Promise.all([ + new Channel(channel).save(), + !opts?.skipEventEmit + ? emitEvent({ + event: "CHANNEL_CREATE", + data: channel, + guild_id: channel.guild_id, + } as ChannelCreateEvent) + : Promise.resolve(), + ]); + + return channel; + } + + static async createDMChannel(recipients: string[], creator_user_id: string, name?: string) { + recipients = recipients.unique().filter((x) => x !== creator_user_id); + const otherRecipientsUsers = await User.find({ where: recipients.map((x) => ({ id: x })) }); + + // TODO: check config for max number of recipients + if (otherRecipientsUsers.length !== recipients.length) { + throw new HTTPError("Recipient/s not found"); + } + + const type = recipients.length === 1 ? ChannelType.DM : ChannelType.GROUP_DM; + + let channel = null; + + const channelRecipients = [...recipients, creator_user_id]; + + const userRecipients = await Recipient.find({ + where: { user_id: creator_user_id }, + relations: ["channel", "channel.recipients"], + }); + + for (let ur of userRecipients) { + let re = ur.channel.recipients!.map((r) => r.user_id); + if (re.length === channelRecipients.length) { + if (containsAll(re, channelRecipients)) { + if (channel == null) { + channel = ur.channel; + await ur.assign({ closed: false }).save(); + } + } + } + } + + if (channel == null) { + name = trimSpecial(name); + + channel = await new Channel({ + name, + type, + owner_id: type === ChannelType.DM ? undefined : creator_user_id, + created_at: new Date(), + last_message_id: null, + recipients: channelRecipients.map( + (x) => + new Recipient({ user_id: x, closed: !(type === ChannelType.GROUP_DM || x === creator_user_id) }) + ), + }).save(); + } + + const channel_dto = await DmChannelDTO.from(channel); + + if (type === ChannelType.GROUP_DM) { + for (let recipient of channel.recipients!) { + await emitEvent({ + event: "CHANNEL_CREATE", + data: channel_dto.excludedRecipients([recipient.user_id]), + user_id: recipient.user_id, + }); + } + } else { + await emitEvent({ event: "CHANNEL_CREATE", data: channel_dto, user_id: creator_user_id }); + } + + return channel_dto.excludedRecipients([creator_user_id]); + } + + static async removeRecipientFromChannel(channel: Channel, user_id: string) { + await Recipient.delete({ channel_id: channel.id, user_id: user_id }); + channel.recipients = channel.recipients?.filter((r) => r.user_id !== user_id); + + if (channel.recipients?.length === 0) { + await Channel.deleteChannel(channel); + await emitEvent({ + event: "CHANNEL_DELETE", + data: await DmChannelDTO.from(channel, [user_id]), + user_id: user_id, + }); + return; + } + + await emitEvent({ + event: "CHANNEL_DELETE", + data: await DmChannelDTO.from(channel, [user_id]), + user_id: user_id, + }); + + //If the owner leave we make the first recipient in the list the new owner + if (channel.owner_id === user_id) { + channel.owner_id = channel.recipients!.find((r) => r.user_id !== user_id)!.user_id; //Is there a criteria to choose the new owner? + await emitEvent({ + event: "CHANNEL_UPDATE", + data: await DmChannelDTO.from(channel, [user_id]), + channel_id: channel.id, + }); + } + + await channel.save(); + + await emitEvent({ + event: "CHANNEL_RECIPIENT_REMOVE", + data: { + channel_id: channel.id, + user: await User.findOneOrFail({ where: { id: user_id }, select: PublicUserProjection }), + }, + channel_id: channel.id, + } as ChannelRecipientRemoveEvent); + } + + static async deleteChannel(channel: Channel) { + await Message.delete({ channel_id: channel.id }); //TODO we should also delete the attachments from the cdn but to do that we need to move cdn.ts in util + //TODO before deleting the channel we should check and delete other relations + await Channel.delete({ id: channel.id }); + } + + isDm() { + return this.type === ChannelType.DM || this.type === ChannelType.GROUP_DM; + } +} + +export interface ChannelPermissionOverwrite { + allow: string; + deny: string; + id: string; + type: ChannelPermissionOverwriteType; +} + +export enum ChannelPermissionOverwriteType { + role = 0, + member = 1, +} diff --git a/util/src/util/InvisibleCharacters.ts b/util/src/util/InvisibleCharacters.ts new file mode 100644 index 00000000..147f51c2 --- /dev/null +++ b/util/src/util/InvisibleCharacters.ts @@ -0,0 +1,55 @@ +export const InvisibleCharacters = [ + "\t", + " ", + "­", + "͏", + "؜", + "ᅟ", + "ᅠ", + "឴", + "឵", + "᠎", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "​", + "‌", + "‍", + "‎", + "‏", + " ", + " ", + "⁠", + "⁡", + "⁢", + "⁣", + "⁤", + "", + "", + "", + "", + "", + "", + " ", + "⠀", + "ㅤ", + "", + "ᅠ", + "𝅙", + "𝅳", + "𝅴", + "𝅵", + "𝅶", + "𝅷", + "𝅸", + "𝅹", + "𝅺" +] \ No newline at end of file diff --git a/util/src/util/index.ts b/util/src/util/index.ts index c5703468..98e1146c 100644 --- a/util/src/util/index.ts +++ b/util/src/util/index.ts @@ -18,3 +18,4 @@ export * from "./Snowflake"; export * from "./String"; export * from "./Array"; export * from "./TraverseDirectory"; +export * from "./InvisibleCharacters"; \ No newline at end of file -- cgit 1.5.1 From 0df2a0adf6da4a86b4c14eb00c2d170191412757 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Thu, 13 Jan 2022 22:57:55 +0300 Subject: Update Channel.ts --- util/src/entities/Channel.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'util/src') diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts index e7e0bace..f0bbfe96 100644 --- a/util/src/entities/Channel.ts +++ b/util/src/entities/Channel.ts @@ -21,11 +21,14 @@ export enum ChannelType { GUILD_CATEGORY = 4, // an organizational category that contains up to 50 channels GUILD_NEWS = 5, // a channel that users can follow and crosspost into their own server GUILD_STORE = 6, // a channel in which game developers can sell their game on Discord - // TODO: what are channel types between 7-9? + ENCRYPTED = 7, // end-to-end encrypted channel + ENCRYPTED_THREAD = 8, // end-to-end encrypted thread channel GUILD_NEWS_THREAD = 10, // a temporary sub-channel within a GUILD_NEWS channel GUILD_PUBLIC_THREAD = 11, // a temporary sub-channel within a GUILD_TEXT channel GUILD_PRIVATE_THREAD = 12, // a temporary sub-channel within a GUILD_TEXT channel that is only viewable by those invited and those with the MANAGE_THREADS permission GUILD_STAGE_VOICE = 13, // a voice channel for hosting events with an audience + CUSTOM_START = 64, // start custom channel types from here + UNHANDLED = 255 // unhandled unowned pass-through channel type } @Entity("channels") @@ -257,7 +260,7 @@ export class Channel extends BaseClass { channel = await new Channel({ name, type, - owner_id: type === ChannelType.DM ? undefined : creator_user_id, + owner_id: type === ChannelType.DM ? undefined : null, // 1:1 DMs are ownerless in fosscord-server created_at: new Date(), last_message_id: null, recipients: channelRecipients.map( @@ -304,9 +307,9 @@ export class Channel extends BaseClass { user_id: user_id, }); - //If the owner leave we make the first recipient in the list the new owner + //If the owner leave the server user is the new owner if (channel.owner_id === user_id) { - channel.owner_id = channel.recipients!.find((r) => r.user_id !== user_id)!.user_id; //Is there a criteria to choose the new owner? + channel.owner_id = 1; // The channel is now owned by the server user await emitEvent({ event: "CHANNEL_UPDATE", data: await DmChannelDTO.from(channel, [user_id]), -- cgit 1.5.1 From 028fd7b8b3fb6a94afce0176f38da1a766f936cc Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sat, 15 Jan 2022 18:00:54 +1100 Subject: Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Erkin Alp Güney --- util/src/entities/Channel.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'util/src') diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts index f0bbfe96..aa1b823e 100644 --- a/util/src/entities/Channel.ts +++ b/util/src/entities/Channel.ts @@ -161,7 +161,8 @@ export class Channel extends BaseClass { if (!opts?.skipNameChecks) { const guild = await Guild.findOneOrFail({ id: channel.guild_id }); - if (!guild.features.includes("ILLEGAL_CHANNEL_NAMES") && channel.name) { + if (!guild.features.includes("ALLOW_INVALID_CHANNEL_NAMES") && channel.name) { + for (var character of InvisibleCharacters) channel.name = channel.name.split(character).join("-"); @@ -169,7 +170,8 @@ export class Channel extends BaseClass { channel.name = channel.name.split("-").filter(Boolean).join("-"); //trim '-' character } - if (!guild.features.includes("NULL_CHANNEL_NAMES")) { + if (!guild.features.includes("ALLOW_UNNAMED_CHANNELS")) { + if (channel.name) channel.name = channel.name.trim(); if (!channel.name) throw new HTTPError("Channel name cannot be empty."); -- cgit 1.5.1 From 0a53860645dbddd4f127988ccd8da0abee7c6f2b Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sat, 15 Jan 2022 18:44:04 +1100 Subject: channel.owner_id is type string not number --- util/src/entities/Channel.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts index aa1b823e..6750a002 100644 --- a/util/src/entities/Channel.ts +++ b/util/src/entities/Channel.ts @@ -311,7 +311,7 @@ export class Channel extends BaseClass { //If the owner leave the server user is the new owner if (channel.owner_id === user_id) { - channel.owner_id = 1; // The channel is now owned by the server user + channel.owner_id = "1"; // The channel is now owned by the server user await emitEvent({ event: "CHANNEL_UPDATE", data: await DmChannelDTO.from(channel, [user_id]), -- cgit 1.5.1 From f8f236afb24d5c806ea0e5981e7f95de6ee4885c Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sat, 15 Jan 2022 18:48:22 +1100 Subject: * Replaced list of invisible characters with unicode codepoints * No longer silently edit invalid channel names * No longer trim channel names in unnamed check --- util/src/entities/Channel.ts | 18 +++--- util/src/util/InvisibleCharacters.ts | 109 ++++++++++++++++++----------------- 2 files changed, 65 insertions(+), 62 deletions(-) (limited to 'util/src') diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts index 6750a002..1cc4a538 100644 --- a/util/src/entities/Channel.ts +++ b/util/src/entities/Channel.ts @@ -162,19 +162,21 @@ export class Channel extends BaseClass { if (!opts?.skipNameChecks) { const guild = await Guild.findOneOrFail({ id: channel.guild_id }); if (!guild.features.includes("ALLOW_INVALID_CHANNEL_NAMES") && channel.name) { - for (var character of InvisibleCharacters) - channel.name = channel.name.split(character).join("-"); + if (channel.name.includes(character)) + throw new HTTPError("Channel name cannot include invalid characters", 403); + + if (channel.name.match(/\-\-+/g)) + throw new HTTPError("Channel name cannot include multiple adjacent dashes.", 403) - channel.name = channel.name.split(/\-+/g).join("-"); //replace multiple occurances with just one - channel.name = channel.name.split("-").filter(Boolean).join("-"); //trim '-' character + if (channel.name.charAt(0) === "-" || + channel.name.charAt(channel.name.length - 1) === "-") + throw new HTTPError("Channel name cannot start/end with dash.", 403) } if (!guild.features.includes("ALLOW_UNNAMED_CHANNELS")) { - - if (channel.name) channel.name = channel.name.trim(); - - if (!channel.name) throw new HTTPError("Channel name cannot be empty."); + if (!channel.name) + throw new HTTPError("Channel name cannot be empty.", 403); } } diff --git a/util/src/util/InvisibleCharacters.ts b/util/src/util/InvisibleCharacters.ts index 147f51c2..2b014e14 100644 --- a/util/src/util/InvisibleCharacters.ts +++ b/util/src/util/InvisibleCharacters.ts @@ -1,55 +1,56 @@ +// List from https://invisible-characters.com/ export const InvisibleCharacters = [ - "\t", - " ", - "­", - "͏", - "؜", - "ᅟ", - "ᅠ", - "឴", - "឵", - "᠎", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - "​", - "‌", - "‍", - "‎", - "‏", - " ", - " ", - "⁠", - "⁡", - "⁢", - "⁣", - "⁤", - "", - "", - "", - "", - "", - "", - " ", - "⠀", - "ㅤ", - "", - "ᅠ", - "𝅙", - "𝅳", - "𝅴", - "𝅵", - "𝅶", - "𝅷", - "𝅸", - "𝅹", - "𝅺" -] \ No newline at end of file + '\u{9}', //Tab + '\u{20}', //Space + '\u{ad}', //Soft hyphen + '\u{34f}', //Combining grapheme joiner + '\u{61c}', //Arabic letter mark + '\u{115f}', //Hangul choseong filler + '\u{1160}', //Hangul jungseong filler + '\u{17b4}', //Khmer vowel inherent AQ + '\u{17b5}', //Khmer vowel inherent AA + '\u{180e}', //Mongolian vowel separator + '\u{2000}', //En quad + '\u{2001}', //Em quad + '\u{2002}', //En space + '\u{2003}', //Em space + '\u{2004}', //Three-per-em space + '\u{2005}', //Four-per-em space + '\u{2006}', //Six-per-em space + '\u{2007}', //Figure space + '\u{2008}', //Punctuation space + '\u{2009}', //Thin space + '\u{200a}', //Hair space + '\u{200b}', //Zero width space + '\u{200c}', //Zero width non-joiner + '\u{200d}', //Zero width joiner + '\u{200e}', //Left-to-right mark + '\u{200f}', //Right-to-left mark + '\u{202f}', //Narrow no-break space + '\u{205f}', //Medium mathematical space + '\u{2060}', //Word joiner + '\u{2061}', //Function application + '\u{2062}', //Invisible times + '\u{2063}', //Invisible separator + '\u{2064}', //Invisible plus + '\u{206a}', //Inhibit symmetric swapping + '\u{206b}', //Activate symmetric swapping + '\u{206c}', //Inhibit arabic form shaping + '\u{206d}', //Activate arabic form shaping + '\u{206e}', //National digit shapes + '\u{206f}', //Nominal digit shapes + '\u{3000}', //Ideographic space + '\u{2800}', //Braille pattern blank + '\u{3164}', //Hangul filler + '\u{feff}', //Zero width no-break space + '\u{ffa0}', //Haldwidth hangul filler + '\u{1d159}', //Musical symbol null notehead + '\u{1d173}', //Musical symbol begin beam + '\u{1d174}', //Musical symbol end beam + '\u{1d175}', //Musical symbol begin tie + '\u{1d176}', //Musical symbol end tie + '\u{1d177}', //Musical symbol begin slur + '\u{1d178}', //Musical symbol end slur + '\u{1d179}', //Musical symbol begin phrase + '\u{1d17a}' //Musical symbol end phrase +]; \ No newline at end of file -- cgit 1.5.1