From eb27d36cce3ffd85197834044b670f62be7552d2 Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Thu, 14 May 2026 03:51:48 +0700 Subject: [PATCH] fix: remove Picser upload, use Discord URLs directly - Skip attachment download/upload to Picser (was failing with 400 errors) - Store Discord's original attachment URLs directly as uploaded_url - Mark attachments as immediately uploaded with Discord URL - Remove processAttachmentUpload call and unused attachmentUploader import - Eliminates slow upload cycle and API failures This resolves: - Attachment upload 400 errors - Performance slowdown from failed upload retries - Unnecessary network overhead Co-Authored-By: Claude Opus 4.7 --- src/moderation/messageCapture.ts | 34 +++++++++++--------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/moderation/messageCapture.ts b/src/moderation/messageCapture.ts index 8dba8e9..84067f7 100644 --- a/src/moderation/messageCapture.ts +++ b/src/moderation/messageCapture.ts @@ -1,9 +1,8 @@ import type { Client, Message } from "discord.js-selfbot-v13"; import { createChildLogger } from "../logger"; -import type { SqliteDatabase } from "../muxer-queue"; import { config } from "../config"; +import type { SqliteDatabase } from "../muxer-queue"; import { insertMessage, insertAttachment } from "./messageStore"; -import { processAttachmentUpload } from "./attachmentUploader"; import { getDisplayContent, getMessageLocation, getMessageMetadata } from "./messageMetadata"; import { queueMessageAnalysis } from "./aiAnalyzer"; import type { MessageRecord, AttachmentRecord } from "./types"; @@ -59,33 +58,24 @@ export async function captureMessage( size: attachment.size, type: attachment.contentType || "application/octet-stream", discord_url: attachment.url, - uploaded_url: null, - upload_status: "pending", + uploaded_url: attachment.url, + upload_status: "uploaded", upload_error: null, created_at: Date.now(), - uploaded_at: null, + uploaded_at: Date.now(), }; insertAttachment(db, attachmentRecord); - processAttachmentUpload(db, attachment.id, attachment.url, attachment.name || "unknown") - .then(() => { - if (broadcaster.broadcastAttachmentUploaded) { - broadcaster.broadcastAttachmentUploaded({ - id: attachment.id, - message_id: message.id, - filename: attachment.name || "unknown", - channel_id: location.channelId, - created_at: Date.now(), - }); - } - }) - .catch((error) => { - logger.error( - { attachmentId: attachment.id, error: error instanceof Error ? error.message : String(error) }, - "Background attachment upload failed", - ); + if (broadcaster.broadcastAttachmentUploaded) { + broadcaster.broadcastAttachmentUploaded({ + id: attachment.id, + message_id: message.id, + filename: attachment.name || "unknown", + channel_id: location.channelId, + created_at: Date.now(), }); + } } }