From c1f079bc6c8d7f71a5efb266f75d345aa2806fc8 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sun, 5 Jan 2025 09:34:58 -0500 Subject: [PATCH] Update MLEnhanced --- src/equicordplugins/messageLoggerEnhanced/index.tsx | 1 - src/equicordplugins/messageLoggerEnhanced/native/index.ts | 6 +++--- .../messageLoggerEnhanced/native/settings.ts | 1 - src/equicordplugins/messageLoggerEnhanced/settings.tsx | 6 ------ src/equicordplugins/messageLoggerEnhanced/utils/misc.ts | 1 + 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/equicordplugins/messageLoggerEnhanced/index.tsx b/src/equicordplugins/messageLoggerEnhanced/index.tsx index 5f4f5b3a..857dbe9b 100644 --- a/src/equicordplugins/messageLoggerEnhanced/index.tsx +++ b/src/equicordplugins/messageLoggerEnhanced/index.tsx @@ -400,4 +400,3 @@ export default definePlugin({ MessageStore.getMessage = this.oldGetMessage; } }); - diff --git a/src/equicordplugins/messageLoggerEnhanced/native/index.ts b/src/equicordplugins/messageLoggerEnhanced/native/index.ts index 5b4d310f..c5060888 100644 --- a/src/equicordplugins/messageLoggerEnhanced/native/index.ts +++ b/src/equicordplugins/messageLoggerEnhanced/native/index.ts @@ -164,8 +164,8 @@ export async function downloadAttachment(_event: IpcMainInvokeEvent, attachemnt: const res = await fetch(useOldUrl ? attachemnt.oldUrl : attachemnt.url); if (res.status !== 200) { - if (res.status === 404 || res.status === 403) - return { error: `Failed to get attachment ${attachemnt.id} for caching, error code ${res.status}`, path: null }; + if (res.status === 404 || res.status === 403 || res.status === 415) + useOldUrl = true; attempts++; if (attempts > 3) { @@ -176,7 +176,7 @@ export async function downloadAttachment(_event: IpcMainInvokeEvent, attachemnt: } await sleep(1000); - return downloadAttachment(_event, attachemnt, attempts, res.status === 415); + return downloadAttachment(_event, attachemnt, attempts, useOldUrl); } const ab = await res.arrayBuffer(); diff --git a/src/equicordplugins/messageLoggerEnhanced/native/settings.ts b/src/equicordplugins/messageLoggerEnhanced/native/settings.ts index f8798983..df541844 100644 --- a/src/equicordplugins/messageLoggerEnhanced/native/settings.ts +++ b/src/equicordplugins/messageLoggerEnhanced/native/settings.ts @@ -47,4 +47,3 @@ async function getSettingsFilePath() { return mlSettingsDir; } - diff --git a/src/equicordplugins/messageLoggerEnhanced/settings.tsx b/src/equicordplugins/messageLoggerEnhanced/settings.tsx index 7479fa6b..00f2bee5 100644 --- a/src/equicordplugins/messageLoggerEnhanced/settings.tsx +++ b/src/equicordplugins/messageLoggerEnhanced/settings.tsx @@ -42,12 +42,6 @@ export const settings = definePluginSettings({ description: "Usually message logger only logs from whitelisted ids and dms, enabling this would mean it would log messages from all servers as well. Note that this may cause the cache to exceed its limit, resulting in some messages being missed. If you are in a lot of servers, this may significantly increase the chances of messages being logged, which can result in a large message record and the inclusion of irrelevant messages.", }, - autoCheckForUpdates: { - default: true, - type: OptionType.BOOLEAN, - description: "Automatically check for updates on startup.", - }, - ignoreBots: { type: OptionType.BOOLEAN, description: "Whether to ignore messages by bots", diff --git a/src/equicordplugins/messageLoggerEnhanced/utils/misc.ts b/src/equicordplugins/messageLoggerEnhanced/utils/misc.ts index 7edceaf3..34dfab23 100644 --- a/src/equicordplugins/messageLoggerEnhanced/utils/misc.ts +++ b/src/equicordplugins/messageLoggerEnhanced/utils/misc.ts @@ -91,6 +91,7 @@ const getTimestamp = (timestamp: any): Date => { export const mapTimestamp = (m: any) => { if (m.timestamp) m.timestamp = getTimestamp(m.timestamp); if (m.editedTimestamp) m.editedTimestamp = getTimestamp(m.editedTimestamp); + if (m.embeds) m.embeds = m.embeds.map(e => sanitizeEmbed(m.channel_id, m.id, e)); return m; };