From 6a78c6561b933631ade04bad8e199a4f811dc2ea Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sat, 9 Jul 2022 14:58:50 +1000 Subject: [PATCH 1/3] Removed unused import tab autocomplete really loves doing this to me --- api/src/routes/channels/#channel_id/messages/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/routes/channels/#channel_id/messages/index.ts b/api/src/routes/channels/#channel_id/messages/index.ts index fc2e4575..54e6edcc 100644 --- a/api/src/routes/channels/#channel_id/messages/index.ts +++ b/api/src/routes/channels/#channel_id/messages/index.ts @@ -17,7 +17,7 @@ import { } from "@fosscord/util"; import { HTTPError } from "lambert-server"; import { handleMessage, postHandleMessage, route } from "@fosscord/api"; -import multer, { Multer } from "multer"; +import multer from "multer"; import { FindManyOptions, LessThan, MoreThan } from "typeorm"; import { URL } from "url"; From 2236cf593ccc2426b5bad5f88d0cd64e7e0e4c17 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sat, 9 Jul 2022 16:01:32 +1000 Subject: [PATCH 2/3] * Make max website preview download size for embeds configurable * Fix Message.update call throwing 'Cannot query across one-to-many for property attachments' --- api/src/util/handlers/Message.ts | 9 ++++++--- util/src/entities/Config.ts | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/api/src/util/handlers/Message.ts b/api/src/util/handlers/Message.ts index e9f0ac55..48f87dfe 100644 --- a/api/src/util/handlers/Message.ts +++ b/api/src/util/handlers/Message.ts @@ -38,7 +38,7 @@ const DEFAULT_FETCH_OPTIONS: any = { headers: { "user-agent": "Mozilla/5.0 (compatible; Fosscord/1.0; +https://github.com/fosscord/fosscord)" }, - size: 1024 * 1024 * 1, + // size: 1024 * 1024 * 5, // grabbed from config later compress: true, method: "GET" }; @@ -154,7 +154,10 @@ export async function postHandleMessage(message: Message) { for (const link of links) { try { - const request = await fetch(link, DEFAULT_FETCH_OPTIONS); + const request = await fetch(link, { + ...DEFAULT_FETCH_OPTIONS, + size: Config.get().limits.message.maxEmbedDownloadSize, + }); const text = await request.text(); const $ = cheerio.load(text); @@ -191,7 +194,7 @@ export async function postHandleMessage(message: Message) { channel_id: message.channel_id, data } as MessageUpdateEvent), - Message.update({ id: message.id, channel_id: message.channel_id }, data) + Message.update({ id: message.id, channel_id: message.channel_id }, { embeds: data.embeds }) ]); } diff --git a/util/src/entities/Config.ts b/util/src/entities/Config.ts index 063a4d4d..75ff4a85 100644 --- a/util/src/entities/Config.ts +++ b/util/src/entities/Config.ts @@ -85,6 +85,7 @@ export interface ConfigValue { maxReactions: number; maxAttachmentSize: number; maxBulkDelete: number; + maxEmbedDownloadSize: number; }; channel: { maxPins: number; @@ -249,6 +250,7 @@ export const DefaultConfigOptions: ConfigValue = { maxTTSCharacters: 200, maxReactions: 20, maxAttachmentSize: 8388608, + maxEmbedDownloadSize: 1024 * 1024 * 5, maxBulkDelete: 100, }, channel: { From 5b912eed5ddfab0f56327a47bb393fbf6f707b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erkin=20Alp=20G=C3=BCney?= Date: Sat, 9 Jul 2022 09:50:02 +0300 Subject: [PATCH 3/3] Relax some of the limits --- util/src/entities/Config.ts | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/util/src/entities/Config.ts b/util/src/entities/Config.ts index 75ff4a85..3756d686 100644 --- a/util/src/entities/Config.ts +++ b/util/src/entities/Config.ts @@ -233,30 +233,30 @@ export const DefaultConfigOptions: ConfigValue = { }, limits: { user: { - maxGuilds: 100, - maxUsername: 32, - maxFriends: 1000, + maxGuilds: 1048576, + maxUsername: 127, + maxFriends: 5000, }, guild: { - maxRoles: 250, - maxEmojis: 50, // TODO: max emojis per guild per nitro level - maxMembers: 250000, - maxChannels: 500, - maxChannelsInCategory: 50, - hideOfflineMember: 1000, + maxRoles: 1000, + maxEmojis: 2000, + maxMembers: 25000000, + maxChannels: 65535, + maxChannelsInCategory: 65535, + hideOfflineMember: 3, }, message: { - maxCharacters: 2000, - maxTTSCharacters: 200, - maxReactions: 20, - maxAttachmentSize: 8388608, + maxCharacters: 1048576, + maxTTSCharacters: 160, + maxReactions: 2048, + maxAttachmentSize: 1024 * 1024 * 1024, maxEmbedDownloadSize: 1024 * 1024 * 5, - maxBulkDelete: 100, + maxBulkDelete: 1000, }, channel: { - maxPins: 50, + maxPins: 500, maxTopic: 1024, - maxWebhooks: 10, + maxWebhooks: 100, }, rate: { disabled: true, @@ -265,9 +265,8 @@ export const DefaultConfigOptions: ConfigValue = { window: 5, }, global: { - count: 20, + count: 250, window: 5, - bot: 250, }, error: { count: 10,