1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-09-20 17:51:35 +02:00

Merge branch 'fix/messageLinkMetas' into slowcord

This commit is contained in:
Madeline 2022-07-09 16:04:03 +10:00
commit a4a72eb9f4
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
2 changed files with 8 additions and 3 deletions

View File

@ -38,7 +38,7 @@ const DEFAULT_FETCH_OPTIONS: any = {
headers: { headers: {
"user-agent": "Mozilla/5.0 (compatible; Fosscord/1.0; +https://github.com/fosscord/fosscord)" "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, compress: true,
method: "GET" method: "GET"
}; };
@ -154,7 +154,10 @@ export async function postHandleMessage(message: Message) {
for (const link of links) { for (const link of links) {
try { 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 text = await request.text();
const $ = cheerio.load(text); const $ = cheerio.load(text);
@ -191,7 +194,7 @@ export async function postHandleMessage(message: Message) {
channel_id: message.channel_id, channel_id: message.channel_id,
data data
} as MessageUpdateEvent), } 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 })
]); ]);
} }

View File

@ -86,6 +86,7 @@ export interface ConfigValue {
maxReactions: number; maxReactions: number;
maxAttachmentSize: number; maxAttachmentSize: number;
maxBulkDelete: number; maxBulkDelete: number;
maxEmbedDownloadSize: number;
}; };
channel: { channel: {
maxPins: number; maxPins: number;
@ -251,6 +252,7 @@ export const DefaultConfigOptions: ConfigValue = {
maxTTSCharacters: 200, maxTTSCharacters: 200,
maxReactions: 20, maxReactions: 20,
maxAttachmentSize: 8388608, maxAttachmentSize: 8388608,
maxEmbedDownloadSize: 1024 * 1024 * 5,
maxBulkDelete: 100, maxBulkDelete: 100,
}, },
channel: { channel: {