From f60ffd3c412482ea38dc68cec45ab1d4d8f6656b Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Thu, 21 Apr 2022 18:50:12 +0300 Subject: user groups - first steps --- util/src/entities/UserGroup.ts | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 util/src/entities/UserGroup.ts (limited to 'util/src') diff --git a/util/src/entities/UserGroup.ts b/util/src/entities/UserGroup.ts new file mode 100644 index 00000000..b32c2d6d --- /dev/null +++ b/util/src/entities/UserGroup.ts @@ -0,0 +1,44 @@ +import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; + +import { BaseClass } from "./BaseClass"; +import { Guild } from "./Guild"; +import { User } from "./User"; + +@Entity("groups") +export class UserGroup extends BaseClass { + @Column() + color: number; + + @Column() + hoist: boolean; + + @JoinColumn({ name: "controller", referencedColumnName: "id" }) + @ManyToOne(() => User) + controller?: User; + + @Column() + mentionable_by?: string; + + @Column() + name: string; + + @Column() + rights: string; + + @Column({ nullable: true }) + icon: string; + + @Column({ type: "simple-json", nullable: true }) + tags?: { + bot_id?: string; + integration_id?: string; + premium_subscriber?: boolean; + }; + + @Column({ nullable: true }) + parent?: string; + + @Column({ type: "simple-array", nullable: true}) + associciations: string[]; + +} -- cgit 1.5.1 From ed69bbbe473b110c7653adbf0793454c39de4041 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Thu, 21 Apr 2022 18:51:40 +0300 Subject: Update UserGroup.ts --- util/src/entities/UserGroup.ts | 7 ------- 1 file changed, 7 deletions(-) (limited to 'util/src') diff --git a/util/src/entities/UserGroup.ts b/util/src/entities/UserGroup.ts index b32c2d6d..709b9d0b 100644 --- a/util/src/entities/UserGroup.ts +++ b/util/src/entities/UserGroup.ts @@ -27,13 +27,6 @@ export class UserGroup extends BaseClass { @Column({ nullable: true }) icon: string; - - @Column({ type: "simple-json", nullable: true }) - tags?: { - bot_id?: string; - integration_id?: string; - premium_subscriber?: boolean; - }; @Column({ nullable: true }) parent?: string; -- cgit 1.5.1 From 1319e0c04e21bb07badede04297bbc4cf8d61854 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sat, 23 Apr 2022 01:28:03 +1000 Subject: Can no longer send messages to channel types that do not support it ( categories, voice etc ) --- api/src/routes/channels/#channel_id/messages/index.ts | 5 +++++ util/src/entities/Channel.ts | 11 +++++++++++ 2 files changed, 16 insertions(+) (limited to 'util/src') diff --git a/api/src/routes/channels/#channel_id/messages/index.ts b/api/src/routes/channels/#channel_id/messages/index.ts index af0ae32d..34cc5ff8 100644 --- a/api/src/routes/channels/#channel_id/messages/index.ts +++ b/api/src/routes/channels/#channel_id/messages/index.ts @@ -183,6 +183,9 @@ router.post( } } const channel = await Channel.findOneOrFail({ where: { id: channel_id }, relations: ["recipients", "recipients.user"] }); + if (!channel.isWritable()) { + throw new HTTPError(`Cannot send messages to channel of type ${channel.type}`, 400) + } const embeds = body.embeds || []; if (body.embed) embeds.push(body.embed); @@ -220,6 +223,8 @@ router.post( }) ); } + + //Fix for the client bug delete message.member diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts index 4bf81901..c516e6a1 100644 --- a/util/src/entities/Channel.ts +++ b/util/src/entities/Channel.ts @@ -352,6 +352,17 @@ export class Channel extends BaseClass { isDm() { 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_VOICE, // TODO: Remove this when clients can send messages to voice channels on discord.com + ChannelType.GUILD_STAGE_VOICE, + ChannelType.VOICELESS_WHITEBOARD, + ]; + return disallowedChannelTypes.indexOf(this.type) == -1; + } } export interface ChannelPermissionOverwrite { -- cgit 1.5.1 From f17cc6bba27ca72b48df858d342c26767372703c Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Fri, 22 Apr 2022 23:03:36 +0300 Subject: text+voice code is already there --- util/src/entities/Channel.ts | 1 - 1 file changed, 1 deletion(-) (limited to 'util/src') diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts index c516e6a1..98766a9d 100644 --- a/util/src/entities/Channel.ts +++ b/util/src/entities/Channel.ts @@ -357,7 +357,6 @@ export class Channel extends BaseClass { isWritable() { const disallowedChannelTypes = [ ChannelType.GUILD_CATEGORY, - ChannelType.GUILD_VOICE, // TODO: Remove this when clients can send messages to voice channels on discord.com ChannelType.GUILD_STAGE_VOICE, ChannelType.VOICELESS_WHITEBOARD, ]; -- cgit 1.5.1 From fc50c8fa81e32c6b3d0ed144f083f2f32fe279f6 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sat, 23 Apr 2022 16:37:16 +0300 Subject: self commands and /me messages --- util/src/entities/Message.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/entities/Message.ts b/util/src/entities/Message.ts index b32bbd94..8bd50455 100644 --- a/util/src/entities/Message.ts +++ b/util/src/entities/Message.ts @@ -39,11 +39,13 @@ export enum MessageType { USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 = 10, USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = 11, CHANNEL_FOLLOW_ADD = 12, + ACTION = 13, // /me messages GUILD_DISCOVERY_DISQUALIFIED = 14, GUILD_DISCOVERY_REQUALIFIED = 15, ENCRYPTED = 16, REPLY = 19, - APPLICATION_COMMAND = 20, + APPLICATION_COMMAND = 20, // application command or self command invocation + SELF_COMMAND_SCRIPT = 21, // self command scripts ROUTE_ADDED = 41, // custom message routing: new route affecting that channel ROUTE_DISABLED = 42, // custom message routing: given route no longer affecting that channel ENCRYPTION = 50, -- cgit 1.5.1 From 7835cb9963d21cd4eac6e95a7db89a827deab253 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sat, 23 Apr 2022 16:40:54 +0300 Subject: Update Message.ts --- util/src/entities/Message.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/entities/Message.ts b/util/src/entities/Message.ts index 8bd50455..e18cf691 100644 --- a/util/src/entities/Message.ts +++ b/util/src/entities/Message.ts @@ -45,9 +45,9 @@ export enum MessageType { ENCRYPTED = 16, REPLY = 19, APPLICATION_COMMAND = 20, // application command or self command invocation - SELF_COMMAND_SCRIPT = 21, // self command scripts ROUTE_ADDED = 41, // custom message routing: new route affecting that channel ROUTE_DISABLED = 42, // custom message routing: given route no longer affecting that channel + SELF_COMMAND_SCRIPT = 43, // self command scripts ENCRYPTION = 50, CUSTOM_START = 63, UNHANDLED = 255 -- cgit 1.5.1 From 08097e157f833cd3cd5b43af9e6adc51dc321f72 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sun, 24 Apr 2022 22:40:36 +0300 Subject: Update Token.ts --- util/src/util/Token.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/util/Token.ts b/util/src/util/Token.ts index 7c4cc61d..500ace45 100644 --- a/util/src/util/Token.ts +++ b/util/src/util/Token.ts @@ -6,7 +6,12 @@ export const JWTOptions: VerifyOptions = { algorithms: ["HS256"] }; export function checkToken(token: string, jwtSecret: string): Promise { return new Promise((res, rej) => { - token = token.replace("Bot ", ""); // TODO: proper bot support + token = token.replace("Bot ", ""); + /** + in fosscord, even with instances that have bot distinction; we won't enforce "Bot" prefix, + as we don't really have separate pathways for bots + **/ + jwt.verify(token, jwtSecret, JWTOptions, async (err, decoded: any) => { if (err || !decoded) return rej("Invalid Token"); -- cgit 1.5.1 From c9c660f7a788dea94f8f5826db96e9a7c7e4e71f Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sun, 24 Apr 2022 23:07:25 +0300 Subject: eventually fix those errors --- api/src/middlewares/RateLimit.ts | 2 +- util/src/util/Constants.ts | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'util/src') diff --git a/api/src/middlewares/RateLimit.ts b/api/src/middlewares/RateLimit.ts index 4bbef520..81668034 100644 --- a/api/src/middlewares/RateLimit.ts +++ b/api/src/middlewares/RateLimit.ts @@ -71,7 +71,7 @@ export default function rateLimit(opts: { if (offender.blocked) { const global = bucket_id === "global"; // each block violation pushes the expiry one full window further - reset = new Date(reset.getTime() + opts.window * 1000); + reset += opts.window * 1000; offender.expires_at = new Date(offender.expires_at.getTime() + opts.window * 1000); resetAfterMs = reset - Date.now(); resetAfterSec = Math.ceil(resetAfterMs / 1000); diff --git a/util/src/util/Constants.ts b/util/src/util/Constants.ts index 8d61b9b4..a5d3fcd2 100644 --- a/util/src/util/Constants.ts +++ b/util/src/util/Constants.ts @@ -727,21 +727,23 @@ export const DiscordApiErrors = { * An error encountered while performing an API request (Fosscord only). Here are the potential errors: */ export const FosscordApiErrors = { - MANUALLY_TRIGGERED_ERROR: new ApiError("This is an artificial error", 1), + MANUALLY_TRIGGERED_ERROR: new ApiError("This is an artificial error", 1, 500), PREMIUM_DISABLED_FOR_GUILD: new ApiError("This guild cannot be boosted", 25001), NO_FURTHER_PREMIUM: new ApiError("This guild does not receive further boosts", 25002), - GUILD_PREMIUM_DISABLED_FOR_YOU: new ApiError("This guild cannot be boosted by you", 25003), + GUILD_PREMIUM_DISABLED_FOR_YOU: new ApiError("This guild cannot be boosted by you", 25003, 403), CANNOT_FRIEND_SELF: new ApiError("Cannot friend oneself", 25009), USER_SPECIFIC_INVITE_WRONG_RECIPIENT: new ApiError("This invite is not meant for you", 25010), USER_SPECIFIC_INVITE_FAILED: new ApiError("Failed to invite user", 25011), - CANNOT_MODIFY_USER_GROUP: new ApiError("This user cannot manipulate this group", 25050), + CANNOT_MODIFY_USER_GROUP: new ApiError("This user cannot manipulate this group", 25050, 403), CANNOT_REMOVE_SELF_FROM_GROUP: new ApiError("This user cannot remove oneself from user group", 25051), CANNOT_BAN_OPERATOR: new ApiError("Non-OPERATOR cannot ban OPERATOR from instance", 25052), - CANNOT_LEAVE_GUILD: new ApiError("You are not allowed to leave guilds that you joined by yourself", 25059), - EDITS_DISABLED: new ApiError("You are not allowed to edit your own messages", 25060), - DELETE_MESSAGE_DISABLED: new ApiError("You are not allowed to delete your own messages", 25061), - FEATURE_PERMANENTLY_DISABLED: new ApiError("This feature has been disabled server-side", 45006), + CANNOT_LEAVE_GUILD: new ApiError("You are not allowed to leave guilds that you joined by yourself", 25059, 403), + EDITS_DISABLED: new ApiError("You are not allowed to edit your own messages", 25060, 403), + DELETE_MESSAGE_DISABLED: new ApiError("You are not allowed to delete your own messages", 25061, 403), + FEATURE_PERMANENTLY_DISABLED: new ApiError("This feature has been disabled server-side", 45006, 501), MISSING_RIGHTS: new ApiError("You lack rights to perform that action ({})", 50013, undefined, [""]), + CANNOT_REPLACE_BY_BACKFILL: new ApiError("Cannot backfill to message ID that already exists", 55002, 409), + CANNOT_BACKFILL_TO_THE_FUTURE: new ApiError("You cannot backfill messages in the future", 55003), CANNOT_GRANT_PERMISSIONS_EXCEEDING_RIGHTS: new ApiError("You cannot grant permissions exceeding your own rights", 50050), ROUTES_LOOPING: new ApiError("Loops in the route definition ({})", 50060, undefined, [""]), CANNOT_REMOVE_ROUTE: new ApiError("Cannot remove message route while it is in effect and being used", 50061), @@ -787,3 +789,4 @@ function keyMirror(arr: string[]) { for (const value of arr) tmp[value] = value; return tmp; } + -- cgit 1.5.1 From 2b1e1a3c0256db22371f1834173e96b29e468d51 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Wed, 27 Apr 2022 21:35:36 +0300 Subject: Forum and guild directory types --- util/src/entities/Channel.ts | 2 ++ 1 file changed, 2 insertions(+) (limited to 'util/src') diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts index 98766a9d..69c08be7 100644 --- a/util/src/entities/Channel.ts +++ b/util/src/entities/Channel.ts @@ -28,6 +28,8 @@ export enum ChannelType { 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 + DIRECTORY = 14, // guild directory listing channel + GUILD_FORUM = 15, // forum composed of IM threads TICKET_TRACKER = 33, // ticket tracker, individual ticket items shall have type 12 KANBAN = 34, // confluence like kanban board VOICELESS_WHITEBOARD = 35, // whiteboard but without voice (whiteboard + voice is the same as stage) -- cgit 1.5.1 From fe06d2b65ba74a69a77976e5304fc5ee2d012cc7 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Tue, 10 May 2022 19:43:28 +0300 Subject: more event types --- util/src/entities/AuditLog.ts | 58 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) (limited to 'util/src') diff --git a/util/src/entities/AuditLog.ts b/util/src/entities/AuditLog.ts index 4b81ed6a..be26374b 100644 --- a/util/src/entities/AuditLog.ts +++ b/util/src/entities/AuditLog.ts @@ -4,41 +4,91 @@ import { ChannelPermissionOverwrite } from "./Channel"; import { User } from "./User"; export enum AuditLogEvents { - GUILD_UPDATE = 1, - CHANNEL_CREATE = 10, + // guild level + GUILD_UPDATE = 1, + GUILD_IMPORT = 2, + GUILD_EXPORTED = 3, + GUILD_ARCHIVE = 4, + GUILD_UNARCHIVE = 5, + // join-leave + USER_JOIN = 6, + USER_LEAVE = 7, + // channels + CHANNEL_CREATE = 10, CHANNEL_UPDATE = 11, CHANNEL_DELETE = 12, - CHANNEL_OVERWRITE_CREATE = 13, + // permission overrides + CHANNEL_OVERWRITE_CREATE = 13, CHANNEL_OVERWRITE_UPDATE = 14, CHANNEL_OVERWRITE_DELETE = 15, - MEMBER_KICK = 20, + // kick and ban + MEMBER_KICK = 20, MEMBER_PRUNE = 21, MEMBER_BAN_ADD = 22, MEMBER_BAN_REMOVE = 23, + // member updates MEMBER_UPDATE = 24, MEMBER_ROLE_UPDATE = 25, MEMBER_MOVE = 26, MEMBER_DISCONNECT = 27, BOT_ADD = 28, + // roles ROLE_CREATE = 30, ROLE_UPDATE = 31, ROLE_DELETE = 32, + ROLE_SWAP = 33, + // invites INVITE_CREATE = 40, INVITE_UPDATE = 41, INVITE_DELETE = 42, + // webhooks WEBHOOK_CREATE = 50, WEBHOOK_UPDATE = 51, WEBHOOK_DELETE = 52, + WEBHOOK_SWAP = 53, + // custom emojis EMOJI_CREATE = 60, EMOJI_UPDATE = 61, EMOJI_DELETE = 62, + EMOJI_SWAP = 63, + // deletion + MESSAGE_CREATE = 70, // messages sent using non-primary seat of the user only + MESSAGE_EDIT = 71, // non-self edits only MESSAGE_DELETE = 72, MESSAGE_BULK_DELETE = 73, + // pinning MESSAGE_PIN = 74, MESSAGE_UNPIN = 75, + // integrations INTEGRATION_CREATE = 80, INTEGRATION_UPDATE = 81, INTEGRATION_DELETE = 82, + // stage actions + STAGE_INSTANCE_CREATE = 83, + STAGE_INSTANCE_UPDATE = 84, + STAGE_INSTANCE_DELETE = 85, + // stickers + STICKER_CREATE = 90, + STICKER_UPDATE = 91, + STICKER_DELETE = 92, + STICKER_SWAP = 93, + // threads + THREAD_CREATE = 110, + THREAD_UPDATE = 111, + THREAD_DELETE = 112, + // application commands + APPLICATION_COMMAND_PERMISSION_UPDATE = 121, + // automod + POLICY_CREATE = 140, + POLICY_UPDATE = 141, + // instance policies affecting the guild + GUILD_CROPPED_BY_POLICIES = 216, + // message moves + IN_GUILD_MESSAGE_MOVE = 223, + CROSS_GUILD_MESSAGE_MOVE = 224, + // message routing + ROUTE_CREATE = 225, + ROUTE_UPDATE = 226, } @Entity("audit_logs") -- cgit 1.5.1 From ce6556db47df28ce4372206dc32c844893ae7780 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Wed, 11 May 2022 00:40:00 +0300 Subject: add more message flags --- util/src/util/MessageFlags.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'util/src') diff --git a/util/src/util/MessageFlags.ts b/util/src/util/MessageFlags.ts index c76be4c8..d8e7bc4f 100644 --- a/util/src/util/MessageFlags.ts +++ b/util/src/util/MessageFlags.ts @@ -1,5 +1,5 @@ -// https://github.com/discordjs/discord.js/blob/master/src/util/MessageFlags.js -// Apache License Version 2.0 Copyright 2015 - 2021 Amish Shah +// based on https://github.com/discordjs/discord.js/blob/master/src/util/MessageFlags.js +// Apache License Version 2.0 Copyright 2015 - 2021 Amish Shah, 2022 Erkin Alp Güney import { BitField } from "./BitField"; @@ -8,7 +8,12 @@ export class MessageFlags extends BitField { CROSSPOSTED: BigInt(1) << BigInt(0), IS_CROSSPOST: BigInt(1) << BigInt(1), SUPPRESS_EMBEDS: BigInt(1) << BigInt(2), - SOURCE_MESSAGE_DELETED: BigInt(1) << BigInt(3), + // SOURCE_MESSAGE_DELETED: BigInt(1) << BigInt(3), // fosscord will delete them from destination too, making this redundant URGENT: BigInt(1) << BigInt(4), + // HAS_THREAD: BigInt(1) << BigInt(5) // does not apply to fosscord due to infrastructural differences + PRIVATE_ROUTE: BigInt(1) << BigInt(6), // it that has been routed to only some of the users that can see the channel + INTERACTION_WAIT: BigInt(1) << BigInt(7), // discord.com calls this LOADING + // FAILED_TO_MENTION_SOME_ROLES_IN_THREAD: BigInt(1) << BigInt(8) + SCRIPT_WAIT: BigInt(1) << BigInt(24) // waiting for the self command to complete }; } -- cgit 1.5.1 From 37543ec0fdeb223ffb46a33207c107081d796b63 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Wed, 11 May 2022 00:43:57 +0300 Subject: Update MessageFlags.ts --- util/src/util/MessageFlags.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/util/MessageFlags.ts b/util/src/util/MessageFlags.ts index d8e7bc4f..b8f8c857 100644 --- a/util/src/util/MessageFlags.ts +++ b/util/src/util/MessageFlags.ts @@ -14,6 +14,7 @@ export class MessageFlags extends BitField { PRIVATE_ROUTE: BigInt(1) << BigInt(6), // it that has been routed to only some of the users that can see the channel INTERACTION_WAIT: BigInt(1) << BigInt(7), // discord.com calls this LOADING // FAILED_TO_MENTION_SOME_ROLES_IN_THREAD: BigInt(1) << BigInt(8) - SCRIPT_WAIT: BigInt(1) << BigInt(24) // waiting for the self command to complete + SCRIPT_WAIT: BigInt(1) << BigInt(24), // waiting for the self command to complete + IMPORT_WAIT: BigInt(1) << BigInt(25), // last message of a channel bulk guild import, waiting for the rest of the channel to be backfilled }; } -- cgit 1.5.1 From 78796c3ce1bca21923e385316956337f0bc8d3fe Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Wed, 11 May 2022 00:44:19 +0300 Subject: Update MessageFlags.ts --- util/src/util/MessageFlags.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/util/MessageFlags.ts b/util/src/util/MessageFlags.ts index b8f8c857..b59295c4 100644 --- a/util/src/util/MessageFlags.ts +++ b/util/src/util/MessageFlags.ts @@ -15,6 +15,6 @@ export class MessageFlags extends BitField { INTERACTION_WAIT: BigInt(1) << BigInt(7), // discord.com calls this LOADING // FAILED_TO_MENTION_SOME_ROLES_IN_THREAD: BigInt(1) << BigInt(8) SCRIPT_WAIT: BigInt(1) << BigInt(24), // waiting for the self command to complete - IMPORT_WAIT: BigInt(1) << BigInt(25), // last message of a channel bulk guild import, waiting for the rest of the channel to be backfilled + IMPORT_WAIT: BigInt(1) << BigInt(25), // latest message of a bulk import, waiting for the rest of the channel to be backfilled }; } -- cgit 1.5.1 From 297115f4c5e626f72bd14f5021465204711424e5 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sun, 15 May 2022 09:12:28 +0300 Subject: user groups --- util/src/entities/Group.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 util/src/entities/Group.ts (limited to 'util/src') diff --git a/util/src/entities/Group.ts b/util/src/entities/Group.ts new file mode 100644 index 00000000..b24d38cf --- /dev/null +++ b/util/src/entities/Group.ts @@ -0,0 +1,33 @@ +import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; + +import { BaseClass } from "./BaseClass"; + +@Entity("groups") +export class UserGroup extends BaseClass { + @Column({ nullable: true }) + parent?: BigInt; + + @Column() + color: number; + + @Column() + hoist: boolean; + + @Column() + mentionable: boolean; + + @Column() + name: string; + + @Column() + rights: BigInt; + + @Column() + position: number; + + @Column({ nullable: true }) + icon: BigInt; + + @Column({ nullable: true }) + unicode_emoji: BigInt; +} -- cgit 1.5.1 From 36d69e781c1df8ca826ebe7b481b263a8476754d Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sun, 15 May 2022 16:28:57 +0300 Subject: Update AuditLog.ts --- util/src/entities/AuditLog.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/entities/AuditLog.ts b/util/src/entities/AuditLog.ts index be26374b..b003e7ba 100644 --- a/util/src/entities/AuditLog.ts +++ b/util/src/entities/AuditLog.ts @@ -81,8 +81,10 @@ export enum AuditLogEvents { // automod POLICY_CREATE = 140, POLICY_UPDATE = 141, + POLICY_DELETE = 142, + MESSAGE_BLOCKED_BY_POLICIES = 143, // in fosscord, blocked messages are stealth-dropped // instance policies affecting the guild - GUILD_CROPPED_BY_POLICIES = 216, + GUILD_AFFECTED_BY_POLICIES = 216, // message moves IN_GUILD_MESSAGE_MOVE = 223, CROSS_GUILD_MESSAGE_MOVE = 224, -- cgit 1.5.1 From 2d177a1082baa846617915b3b66b66af9a390f61 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sun, 15 May 2022 17:52:17 +0300 Subject: Extended settings --- util/src/entities/User.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'util/src') diff --git a/util/src/entities/User.ts b/util/src/entities/User.ts index a5c4c136..558a4190 100644 --- a/util/src/entities/User.ts +++ b/util/src/entities/User.ts @@ -163,6 +163,10 @@ export class User extends BaseClass { @Column({ type: "simple-json", select: false }) settings: UserSettings; + + // workaround to prevent fossord-unaware clients from deleting settings not used by them + @Column({ type: "simple-json", select: false }) + extended_settings: UserSettings; @Column({ type: "simple-json" }) notes: { [key: string]: string }; //key is ID of user @@ -273,6 +277,7 @@ export class User extends BaseClass { valid_tokens_since: new Date(), }, settings: { ...defaultSettings, locale: language }, + extended_settings: {}, fingerprints: [], notes: {}, }); -- cgit 1.5.1 From d8d2c28fca31d9426265a51a6713bc4c1757880a Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sun, 15 May 2022 17:53:24 +0300 Subject: Extended settings will not be type checked --- util/src/entities/User.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/entities/User.ts b/util/src/entities/User.ts index 558a4190..9b1c494e 100644 --- a/util/src/entities/User.ts +++ b/util/src/entities/User.ts @@ -166,7 +166,7 @@ export class User extends BaseClass { // workaround to prevent fossord-unaware clients from deleting settings not used by them @Column({ type: "simple-json", select: false }) - extended_settings: UserSettings; + extended_settings: string; @Column({ type: "simple-json" }) notes: { [key: string]: string }; //key is ID of user -- cgit 1.5.1 From 7e0454c85f411199ea386adb5d8601593cc4cbb0 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Thu, 19 May 2022 23:11:46 +0300 Subject: add guild policies --- util/src/util/Intents.ts | 2 ++ 1 file changed, 2 insertions(+) (limited to 'util/src') diff --git a/util/src/util/Intents.ts b/util/src/util/Intents.ts index d9a60e4a..1e840b76 100644 --- a/util/src/util/Intents.ts +++ b/util/src/util/Intents.ts @@ -18,6 +18,8 @@ export class Intents extends BitField { DIRECT_MESSAGE_REACTIONS: BigInt(1) << BigInt(13), // DM or orphan channel message reactions DIRECT_MESSAGE_TYPING: BigInt(1) << BigInt(14), // DM typing notifications GUILD_MESSAGES_CONTENT: BigInt(1) << BigInt(15), // guild message content + GUILD_POLICIES: BigInt(1) << BigInt(20), // guild policies + GUILD_POLICY_EXECUTION: BigInt(1) << BigInt(21), // guild policy execution LIVE_MESSAGE_COMPOSITION: BigInt(1) << BigInt(32), // allow composing messages using the gateway GUILD_ROUTES: BigInt(1) << BigInt(41), // message routes affecting the guild DIRECT_MESSAGES_THREADS: BigInt(1) << BigInt(42), // direct message threads -- cgit 1.5.1 From ad1aafa7c6e4ef76fc2529efd4c8eef915f4c4ec Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Mon, 30 May 2022 23:28:23 +1000 Subject: Respect register_dateOfBirth_required = false --- api/src/routes/auth/register.ts | 2 +- util/src/entities/Config.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'util/src') diff --git a/api/src/routes/auth/register.ts b/api/src/routes/auth/register.ts index cd1bcb72..94dd6502 100644 --- a/api/src/routes/auth/register.ts +++ b/api/src/routes/auth/register.ts @@ -128,7 +128,7 @@ router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Re throw FieldErrors({ date_of_birth: { code: "BASE_TYPE_REQUIRED", message: req.t("common:field.BASE_TYPE_REQUIRED") } }); - } else if (register.dateOfBirth.minimum) { + } else if (register.dateOfBirth.required && register.dateOfBirth.minimum) { const minimum = new Date(); minimum.setFullYear(minimum.getFullYear() - register.dateOfBirth.minimum); body.date_of_birth = new Date(body.date_of_birth as Date); diff --git a/util/src/entities/Config.ts b/util/src/entities/Config.ts index 8d29b387..063a4d4d 100644 --- a/util/src/entities/Config.ts +++ b/util/src/entities/Config.ts @@ -324,7 +324,7 @@ export const DefaultConfigOptions: ConfigValue = { // domains: fs.readFileSync(__dirname + "/blockedEmailDomains.txt", { encoding: "utf8" }).split("\n"), }, dateOfBirth: { - required: false, + required: true, minimum: 13, }, disabled: false, -- cgit 1.5.1