diff --git a/assets/openapi.json b/assets/openapi.json index 5f61546..1805c9a 100644 --- a/assets/openapi.json +++ b/assets/openapi.json @@ -4481,7 +4481,7 @@ "sending_dns_records": { "type": "array", "items": { - "$ref": "#/components/schemas/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Types/Domains/Domains\",{with:{\"resolution-mode\":\"import\"}}).DNSRecord" + "$ref": "#/components/schemas/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Types/Domains/Domains\",{with:{\"resolution-mode\":\"import\"}}).DNSRecord" } } }, @@ -8004,7 +8004,7 @@ "type": "string" }, "template": { - "$ref": "#/components/schemas/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/components/schemas/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "additionalProperties": false, @@ -8031,7 +8031,7 @@ "items": { "type": "array", "items": { - "$ref": "#/components/schemas/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/components/schemas/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "paging": { @@ -8081,7 +8081,7 @@ "type": "object", "properties": { "template": { - "$ref": "#/components/schemas/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/components/schemas/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "additionalProperties": false, @@ -8169,7 +8169,7 @@ "type": "string" }, "template": { - "$ref": "#/components/schemas/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/components/schemas/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "additionalProperties": false, @@ -9223,7 +9223,7 @@ "type": "object", "properties": { "body": { - "$ref": "#/components/schemas/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Types/Suppressions/Suppressions\",{with:{\"resolution-mode\":\"import\"}}).SuppressionDataType" + "$ref": "#/components/schemas/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Types/Suppressions/Suppressions\",{with:{\"resolution-mode\":\"import\"}}).SuppressionDataType" }, "status": { "type": "integer" @@ -9917,96 +9917,86 @@ "type": "integer" }, "Data": { + "additionalProperties": false, "type": "array", - "items": { - "additionalProperties": false, - "type": "object", - "properties": { - "Author": { - "type": "string" - }, - "Categories": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Template.Categories" - } - }, - "Copyright": { - "type": "string" - }, - "Description": { - "type": "string" - }, - "EditMode": { - "$ref": "#/components/schemas/Template.EditMode" - }, - "IsStarred": { - "type": "boolean" - }, - "IsTextPartGenerationEnabled": { - "type": "boolean" - }, - "Locale": { - "type": "string" - }, - "Name": { - "type": "string" - }, - "OwnerType": { - "$ref": "#/components/schemas/Template.OwnerType" - }, - "Presets": { - "type": "string" - }, - "Purposes": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Template.Purposes" - } - }, - "ID": { - "type": "integer" - }, - "OwnerId": { - "type": "integer" - }, - "Previews": { - "type": "string" - }, - "CreatedAt": { - "type": "string" - }, - "LastUpdatedAt": { - "type": "string" - }, - "LocaleList": { - "type": "array", - "items": { - "type": "string" - } + "properties": { + "Author": { + "type": "string" + }, + "Categories": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Template.Categories" } }, - "required": [ - "Author", - "Categories", - "Copyright", - "CreatedAt", - "Description", - "EditMode", - "ID", - "IsStarred", - "IsTextPartGenerationEnabled", - "LastUpdatedAt", - "Locale", - "LocaleList", - "Name", - "OwnerId", - "OwnerType", - "Presets", - "Previews", - "Purposes" - ] - } + "Copyright": { + "type": "string" + }, + "Description": { + "type": "string" + }, + "EditMode": { + "$ref": "#/components/schemas/Template.EditMode" + }, + "IsStarred": { + "type": "boolean" + }, + "IsTextPartGenerationEnabled": { + "type": "boolean" + }, + "Locale": { + "type": "string" + }, + "Name": { + "type": "string" + }, + "OwnerType": { + "$ref": "#/components/schemas/Template.OwnerType" + }, + "Presets": { + "type": "string" + }, + "Purposes": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Template.Purposes" + } + }, + "ID": { + "type": "integer" + }, + "OwnerId": { + "type": "integer" + }, + "Previews": { + "type": "string" + }, + "CreatedAt": { + "type": "string" + }, + "LastUpdatedAt": { + "type": "string" + } + }, + "required": [ + "Author", + "Categories", + "Copyright", + "CreatedAt", + "Description", + "EditMode", + "ID", + "IsStarred", + "IsTextPartGenerationEnabled", + "LastUpdatedAt", + "Locale", + "Name", + "OwnerId", + "OwnerType", + "Presets", + "Previews", + "Purposes" + ] } }, "required": [ @@ -17834,7 +17824,7 @@ "length": { "type": "integer" }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "object", "additionalProperties": false, "patternProperties": { @@ -17993,17 +17983,17 @@ "except": { "type": "boolean" }, - "__@iterator@698": { + "__@iterator@689": { "type": "boolean" }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "boolean" } } } }, "required": [ - "__@unscopables@700", + "__@unscopables@691", "length" ] }, diff --git a/assets/schemas.json b/assets/schemas.json index 0b0307d..a60d85e 100644 --- a/assets/schemas.json +++ b/assets/schemas.json @@ -10712,7 +10712,7 @@ "sending_dns_records": { "type": "array", "items": { - "$ref": "#/definitions/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Types/Domains/Domains\",{with:{\"resolution-mode\":\"import\"}}).DNSRecord" + "$ref": "#/definitions/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Types/Domains/Domains\",{with:{\"resolution-mode\":\"import\"}}).DNSRecord" } } }, @@ -10733,7 +10733,7 @@ "status" ], "definitions": { - "import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Types/Domains/Domains\",{with:{\"resolution-mode\":\"import\"}}).DNSRecord": { + "import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Types/Domains/Domains\",{with:{\"resolution-mode\":\"import\"}}).DNSRecord": { "type": "object", "properties": { "cached": { @@ -14335,7 +14335,7 @@ "type": "string" }, "template": { - "$ref": "#/definitions/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/definitions/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "additionalProperties": false, @@ -14351,7 +14351,7 @@ "status" ], "definitions": { - "import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { + "import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { "type": "object", "properties": { "name": { @@ -14378,7 +14378,7 @@ "type": "string" }, "version": { - "$ref": "#/definitions/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" + "$ref": "#/definitions/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" }, "versions": { "type": "array", @@ -14437,7 +14437,7 @@ "name" ] }, - "import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { + "import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { "additionalProperties": false, "type": "object", "properties": { @@ -14515,7 +14515,7 @@ "items": { "type": "array", "items": { - "$ref": "#/definitions/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/definitions/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "paging": { @@ -14556,7 +14556,7 @@ "status" ], "definitions": { - "import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { + "import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { "type": "object", "properties": { "name": { @@ -14583,7 +14583,7 @@ "type": "string" }, "version": { - "$ref": "#/definitions/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" + "$ref": "#/definitions/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" }, "versions": { "type": "array", @@ -14642,7 +14642,7 @@ "name" ] }, - "import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { + "import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { "additionalProperties": false, "type": "object", "properties": { @@ -14718,7 +14718,7 @@ "type": "object", "properties": { "template": { - "$ref": "#/definitions/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/definitions/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "additionalProperties": false, @@ -14733,7 +14733,7 @@ "status" ], "definitions": { - "import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { + "import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { "type": "object", "properties": { "name": { @@ -14760,7 +14760,7 @@ "type": "string" }, "version": { - "$ref": "#/definitions/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" + "$ref": "#/definitions/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" }, "versions": { "type": "array", @@ -14819,7 +14819,7 @@ "name" ] }, - "import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { + "import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { "additionalProperties": false, "type": "object", "properties": { @@ -14963,7 +14963,7 @@ "type": "string" }, "template": { - "$ref": "#/definitions/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/definitions/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "additionalProperties": false, @@ -14979,7 +14979,7 @@ "status" ], "definitions": { - "import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { + "import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { "type": "object", "properties": { "name": { @@ -15006,7 +15006,7 @@ "type": "string" }, "version": { - "$ref": "#/definitions/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" + "$ref": "#/definitions/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" }, "versions": { "type": "array", @@ -15065,7 +15065,7 @@ "name" ] }, - "import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { + "import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { "additionalProperties": false, "type": "object", "properties": { @@ -16198,7 +16198,7 @@ "type": "object", "properties": { "body": { - "$ref": "#/definitions/import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Types/Suppressions/Suppressions\",{with:{\"resolution-mode\":\"import\"}}).SuppressionDataType" + "$ref": "#/definitions/import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Types/Suppressions/Suppressions\",{with:{\"resolution-mode\":\"import\"}}).SuppressionDataType" }, "status": { "type": "integer" @@ -16210,7 +16210,7 @@ "status" ], "definitions": { - "import(\"/home/Rory/git/spacebar/server-master/node_modules/mailgun.js/Types/Types/Suppressions/Suppressions\",{with:{\"resolution-mode\":\"import\"}}).SuppressionDataType": { + "import(\"/home/mathman05/Downloads/server5/server/node_modules/mailgun.js/Types/Types/Suppressions/Suppressions\",{with:{\"resolution-mode\":\"import\"}}).SuppressionDataType": { "anyOf": [ { "type": "object", @@ -16838,22 +16838,6 @@ "$ref": "#/definitions/Omit" } ] - }, - "httpVersion": { - "enum": [ - 1, - 2 - ], - "type": "number" - }, - "http2Options": { - "additionalProperties": false, - "type": "object", - "properties": { - "sessionTimeout": { - "type": "integer" - } - } } }, "additionalProperties": false, @@ -17119,13 +17103,13 @@ "Promise": { "type": "object", "properties": { - "__@toStringTag@1303": { + "__@toStringTag@1294": { "type": "string" } }, "additionalProperties": false, "required": [ - "__@toStringTag@1303" + "__@toStringTag@1294" ] }, "Cancel": { @@ -17552,96 +17536,86 @@ "type": "integer" }, "Data": { + "additionalProperties": false, "type": "array", - "items": { - "additionalProperties": false, - "type": "object", - "properties": { - "Author": { - "type": "string" - }, - "Categories": { - "type": "array", - "items": { - "$ref": "#/definitions/Template.Categories" - } - }, - "Copyright": { - "type": "string" - }, - "Description": { - "type": "string" - }, - "EditMode": { - "$ref": "#/definitions/Template.EditMode" - }, - "IsStarred": { - "type": "boolean" - }, - "IsTextPartGenerationEnabled": { - "type": "boolean" - }, - "Locale": { - "type": "string" - }, - "Name": { - "type": "string" - }, - "OwnerType": { - "$ref": "#/definitions/Template.OwnerType" - }, - "Presets": { - "type": "string" - }, - "Purposes": { - "type": "array", - "items": { - "$ref": "#/definitions/Template.Purposes" - } - }, - "ID": { - "type": "integer" - }, - "OwnerId": { - "type": "integer" - }, - "Previews": { - "type": "string" - }, - "CreatedAt": { - "type": "string" - }, - "LastUpdatedAt": { - "type": "string" - }, - "LocaleList": { - "type": "array", - "items": { - "type": "string" - } + "properties": { + "Author": { + "type": "string" + }, + "Categories": { + "type": "array", + "items": { + "$ref": "#/definitions/Template.Categories" } }, - "required": [ - "Author", - "Categories", - "Copyright", - "CreatedAt", - "Description", - "EditMode", - "ID", - "IsStarred", - "IsTextPartGenerationEnabled", - "LastUpdatedAt", - "Locale", - "LocaleList", - "Name", - "OwnerId", - "OwnerType", - "Presets", - "Previews", - "Purposes" - ] - } + "Copyright": { + "type": "string" + }, + "Description": { + "type": "string" + }, + "EditMode": { + "$ref": "#/definitions/Template.EditMode" + }, + "IsStarred": { + "type": "boolean" + }, + "IsTextPartGenerationEnabled": { + "type": "boolean" + }, + "Locale": { + "type": "string" + }, + "Name": { + "type": "string" + }, + "OwnerType": { + "$ref": "#/definitions/Template.OwnerType" + }, + "Presets": { + "type": "string" + }, + "Purposes": { + "type": "array", + "items": { + "$ref": "#/definitions/Template.Purposes" + } + }, + "ID": { + "type": "integer" + }, + "OwnerId": { + "type": "integer" + }, + "Previews": { + "type": "string" + }, + "CreatedAt": { + "type": "string" + }, + "LastUpdatedAt": { + "type": "string" + } + }, + "required": [ + "Author", + "Categories", + "Copyright", + "CreatedAt", + "Description", + "EditMode", + "ID", + "IsStarred", + "IsTextPartGenerationEnabled", + "LastUpdatedAt", + "Locale", + "Name", + "OwnerId", + "OwnerType", + "Presets", + "Previews", + "Purposes" + ] } }, "additionalProperties": false, @@ -58267,7 +58241,7 @@ "length": { "type": "integer" }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "object", "additionalProperties": false, "patternProperties": { @@ -58426,17 +58400,17 @@ "except": { "type": "boolean" }, - "__@iterator@698": { + "__@iterator@689": { "type": "boolean" }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "boolean" } } } }, "required": [ - "__@unscopables@700", + "__@unscopables@691", "length" ] }, @@ -58490,7 +58464,7 @@ "length": { "type": "integer" }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "object", "additionalProperties": false, "patternProperties": { @@ -58649,17 +58623,17 @@ "except": { "type": "boolean" }, - "__@iterator@698": { + "__@iterator@689": { "type": "boolean" }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "boolean" } } } }, "required": [ - "__@unscopables@700", + "__@unscopables@691", "length" ] }, @@ -117789,7 +117763,7 @@ "length": { "type": "integer" }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "object", "additionalProperties": false, "patternProperties": { @@ -117948,17 +117922,17 @@ "except": { "type": "boolean" }, - "__@iterator@698": { + "__@iterator@689": { "type": "boolean" }, - "__@unscopables@700": { + "__@unscopables@691": { "type": "boolean" } } } }, "required": [ - "__@unscopables@700", + "__@unscopables@691", "length" ] }, diff --git a/src/gateway/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts index 46c7db6..7b9f107 100644 --- a/src/gateway/opcodes/Identify.ts +++ b/src/gateway/opcodes/Identify.ts @@ -452,7 +452,6 @@ const channelUsers = channel.recipients?.map((recipient) => recipient.user.toPublicUser()); if (channelUsers && channelUsers.length > 0) channelUsers.forEach((user) => users.add(user)); - return { id: channel.id, flags: channel.flags, @@ -462,6 +461,7 @@ icon: channel.icon, name: channel.name, is_spam: false, // TODO + owner_id: channel.owner_id, }; }); const generateDmChannelsTime = taskSw.getElapsedAndReset(); diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts index 3c11de3..a599572 100644 --- a/src/util/entities/Channel.ts +++ b/src/util/entities/Channel.ts @@ -17,14 +17,7 @@ */ import { HTTPError } from "lambert-server"; -import { - Column, - Entity, - JoinColumn, - ManyToOne, - OneToMany, - RelationId, -} from "typeorm"; +import { Column, Entity, JoinColumn, ManyToOne, OneToMany, RelationId } from "typeorm"; import { DmChannelDTO } from "../dtos"; import { ChannelCreateEvent, ChannelRecipientRemoveEvent } from "../interfaces"; import { InvisibleCharacters, Snowflake, emitEvent, getPermission, trimSpecial, Permissions, BitField } from "../util"; @@ -135,14 +128,10 @@ }) messages?: Message[]; - @OneToMany( - () => VoiceState, - (voice_state: VoiceState) => voice_state.channel, - { - cascade: true, - orphanedRowAction: "delete", - }, - ) + @OneToMany(() => VoiceState, (voice_state: VoiceState) => voice_state.channel, { + cascade: true, + orphanedRowAction: "delete", + }) voice_states?: VoiceState[]; @OneToMany(() => ReadState, (read_state: ReadState) => read_state.channel, { @@ -194,48 +183,22 @@ }); if (!opts?.skipNameChecks) { - if ( - !guild.features.includes("ALLOW_INVALID_CHANNEL_NAMES") && - channel.name - ) { - for (const character of InvisibleCharacters) - if (channel.name.includes(character)) - throw new HTTPError( - "Channel name cannot include invalid characters", - 403, - ); + if (!guild.features.includes("ALLOW_INVALID_CHANNEL_NAMES") && channel.name) { + for (const character of InvisibleCharacters) if (channel.name.includes(character)) throw new HTTPError("Channel name cannot include invalid characters", 403); // Categories skip these checks on discord.com - if ( - channel.type !== ChannelType.GUILD_CATEGORY || - guild.features.includes("IRC_LIKE_CATEGORY_NAMES") - ) { - if (channel.name.includes(" ")) - throw new HTTPError( - "Channel name cannot include invalid characters", - 403, - ); + if (channel.type !== ChannelType.GUILD_CATEGORY || guild.features.includes("IRC_LIKE_CATEGORY_NAMES")) { + if (channel.name.includes(" ")) 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, - ); + if (channel.name.match(/--+/g)) throw new HTTPError("Channel name cannot include multiple adjacent dashes.", 403); - if ( - channel.name.charAt(0) === "-" || - channel.name.charAt(channel.name.length - 1) === "-" - ) - throw new HTTPError( - "Channel name cannot start/end with dash.", - 403, - ); + if (channel.name.charAt(0) === "-" || channel.name.charAt(channel.name.length - 1) === "-") + throw new HTTPError("Channel name cannot start/end with dash.", 403); } else channel.name = channel.name.trim(); //category names are trimmed client side on discord.com } if (!guild.features.includes("ALLOW_UNNAMED_CHANNELS")) { - if (!channel.name) - throw new HTTPError("Channel name cannot be empty.", 403); + if (!channel.name) throw new HTTPError("Channel name cannot be empty.", 403); } } @@ -247,15 +210,8 @@ const exists = await Channel.findOneOrFail({ where: { 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", - ); + 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: @@ -272,9 +228,7 @@ if (!channel.permission_overwrites) channel.permission_overwrites = []; // TODO: eagerly auto generate position of all guild channels - const position = - (channel.type === ChannelType.UNHANDLED ? 0 : channel.position) || - 0; + const position = (channel.type === ChannelType.UNHANDLED ? 0 : channel.position) || 0; channel = { ...channel, @@ -300,11 +254,7 @@ return ret; } - static async createDMChannel( - recipients: string[], - creator_user_id: string, - name?: string, - ) { + static async createDMChannel(recipients: string[], creator_user_id: string, name?: string) { recipients = recipients.distinct().filter((x) => x !== creator_user_id); // TODO: check config for max number of recipients /** if you want to disallow note to self channels, uncomment the conditional below @@ -315,8 +265,7 @@ } **/ - const type = - recipients.length > 1 ? ChannelType.GROUP_DM : ChannelType.DM; + const type = recipients.length > 1 ? ChannelType.GROUP_DM : ChannelType.DM; let channel = null; @@ -346,16 +295,13 @@ channel = await Channel.create({ name, type, - owner_id: undefined, + owner_id: creator_user_id, created_at: new Date(), last_message_id: undefined, recipients: channelRecipients.map((x) => Recipient.create({ user_id: x, - closed: !( - type === ChannelType.GROUP_DM || - x === creator_user_id - ), + closed: !(type === ChannelType.GROUP_DM || x === creator_user_id), }), ), nsfw: false, @@ -386,9 +332,7 @@ 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, - ); + channel.recipients = channel.recipients?.filter((r) => r.user_id !== user_id); if (channel.recipients?.length === 0) { await Channel.deleteChannel(channel); @@ -440,20 +384,11 @@ select: { channel_ordering: true }, }); - const updatedOrdering = guild.channel_ordering.filter( - (id) => id != channel.id, - ); - await Guild.update( - { id: channel.guild_id }, - { channel_ordering: updatedOrdering }, - ); + const updatedOrdering = guild.channel_ordering.filter((id) => id != channel.id); + await Guild.update({ id: channel.guild_id }, { channel_ordering: updatedOrdering }); } - static async calculatePosition( - channel_id: string, - guild_id: string, - guild?: Guild, - ) { + static async calculatePosition(channel_id: string, guild_id: string, guild?: Guild) { if (!guild) guild = await Guild.findOneOrFail({ where: { id: guild_id }, @@ -470,11 +405,7 @@ select: { channel_ordering: true }, }); - const channels = await Promise.all( - guild.channel_ordering.map((id) => - Channel.findOne({ where: { id } }), - ), - ); + const channels = await Promise.all(guild.channel_ordering.map((id) => Channel.findOne({ where: { id } }))); return channels .filter((channel) => channel !== null) @@ -488,22 +419,16 @@ } isDm() { - return ( - this.type === ChannelType.DM || this.type === ChannelType.GROUP_DM - ); + return this.type === ChannelType.DM || this.type === ChannelType.GROUP_DM; } // Does the channel support sending messages ( eg categories do not ) isWritable() { - const disallowedChannelTypes = [ - ChannelType.GUILD_CATEGORY, - ChannelType.GUILD_STAGE_VOICE, - ChannelType.VOICELESS_WHITEBOARD, - ]; + const disallowedChannelTypes = [ChannelType.GUILD_CATEGORY, ChannelType.GUILD_STAGE_VOICE, ChannelType.VOICELESS_WHITEBOARD]; return disallowedChannelTypes.indexOf(this.type) == -1; } - async getUserPermissions(opts: {user_id?: string, user?: User, member?: Member, guild?: Guild}): Promise { + async getUserPermissions(opts: { user_id?: string; user?: User; member?: Member; guild?: Guild }): Promise { let guild = opts.guild; if (!guild) { if (this.guild) guild = this.guild; @@ -523,20 +448,21 @@ let member = opts.member; if (!member) { - if (opts.user) member = await Member.findOneOrFail({ where: { guild_id: guild.id, id: opts.user.id }, relations: [ "roles" ] }); - else if (opts.user_id) member = await Member.findOneOrFail({ where: { guild_id: guild.id, id: opts.user_id }, relations: [ "roles" ] }); + if (opts.user) member = await Member.findOneOrFail({ where: { guild_id: guild.id, id: opts.user.id }, relations: ["roles"] }); + else if (opts.user_id) member = await Member.findOneOrFail({ where: { guild_id: guild.id, id: opts.user_id }, relations: ["roles"] }); else { console.error("Channel.getUserPermissions: called without user or member for non-DM channel."); return Permissions.NONE; } } - const roles = (member.roles || (await Member.findOneOrFail({ where: { guild_id: guild.id, index: member.index }, relations: [ "roles" ] })).roles) - .sort((a, b) => a.position - b.position); // ascending by position + const roles = (member.roles || (await Member.findOneOrFail({ where: { guild_id: guild.id, index: member.index }, relations: ["roles"] })).roles).sort( + (a, b) => a.position - b.position, + ); // ascending by position // calculate user's channel perms - should in theory match https://docs.discord.food/topics/permissions#permission-overwrites // start at role permissions - let userPerms = new Permissions(new BitField(0).add(roles.map(r => r.permissions))); + let userPerms = new Permissions(new BitField(0).add(roles.map((r) => r.permissions))); // TODO: do we want to have an instance-wide opt out of this behavior? It would just be an extra if statement here if (userPerms.has(Permissions.FLAGS.ADMINISTRATOR)) return userPerms; @@ -544,11 +470,11 @@ // apply channel overrides if (this.permission_overwrites) { // role overwrites - TODO: this probably violates the geneva conventions - we should probably be ordering roles here - for (const overwrite of this.permission_overwrites.filter(o => o.type === ChannelPermissionOverwriteType.role && roles.map(r => r.id).includes(o.id))) + for (const overwrite of this.permission_overwrites.filter((o) => o.type === ChannelPermissionOverwriteType.role && roles.map((r) => r.id).includes(o.id))) userPerms = new Permissions(userPerms.remove(overwrite.deny).add(overwrite.allow)); // member overwrite, throws if somehow we have multiple overwrites for the same member - const memberOverwrite = this.permission_overwrites.single(o => o.type === ChannelPermissionOverwriteType.member && o.id === member?.id); + const memberOverwrite = this.permission_overwrites.single((o) => o.type === ChannelPermissionOverwriteType.member && o.id === member?.id); if (memberOverwrite) userPerms = new Permissions(userPerms.remove(memberOverwrite.deny).add(memberOverwrite.allow)); } @@ -556,8 +482,8 @@ } // TODO: should we throw for missing args? - async canViewChannel(opts: {user_id?: string, user?: User, member?: Member, guild?: Guild}): Promise { - if(this.isDm()) return await this.canViewDmChannel(opts.user_id, opts.user); + async canViewChannel(opts: { user_id?: string; user?: User; member?: Member; guild?: Guild }): Promise { + if (this.isDm()) return await this.canViewDmChannel(opts.user_id, opts.user); const userPerms = await this.getUserPermissions(opts); return userPerms.has("VIEW_CHANNEL"); @@ -570,9 +496,9 @@ return false; } if (!user) return false; - if (this.recipients) - return this.recipients.some((r) => r.user_id === user.id && !r.closed); - else { // we dont have recipients on hand + if (this.recipients) return this.recipients.some((r) => r.user_id === user.id && !r.closed); + else { + // we dont have recipients on hand const recipient = await Recipient.findOne({ where: { channel_id: this.id, user_id: user.id } }); return recipient == null ? false : !recipient.closed; }