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 <noreply@anthropic.com>
This commit is contained in:
MythEclipse
2026-05-14 03:51:48 +07:00
parent 0a5cedfed1
commit eb27d36cce

View File

@@ -1,9 +1,8 @@
import type { Client, Message } from "discord.js-selfbot-v13"; import type { Client, Message } from "discord.js-selfbot-v13";
import { createChildLogger } from "../logger"; import { createChildLogger } from "../logger";
import type { SqliteDatabase } from "../muxer-queue";
import { config } from "../config"; import { config } from "../config";
import type { SqliteDatabase } from "../muxer-queue";
import { insertMessage, insertAttachment } from "./messageStore"; import { insertMessage, insertAttachment } from "./messageStore";
import { processAttachmentUpload } from "./attachmentUploader";
import { getDisplayContent, getMessageLocation, getMessageMetadata } from "./messageMetadata"; import { getDisplayContent, getMessageLocation, getMessageMetadata } from "./messageMetadata";
import { queueMessageAnalysis } from "./aiAnalyzer"; import { queueMessageAnalysis } from "./aiAnalyzer";
import type { MessageRecord, AttachmentRecord } from "./types"; import type { MessageRecord, AttachmentRecord } from "./types";
@@ -59,17 +58,15 @@ export async function captureMessage(
size: attachment.size, size: attachment.size,
type: attachment.contentType || "application/octet-stream", type: attachment.contentType || "application/octet-stream",
discord_url: attachment.url, discord_url: attachment.url,
uploaded_url: null, uploaded_url: attachment.url,
upload_status: "pending", upload_status: "uploaded",
upload_error: null, upload_error: null,
created_at: Date.now(), created_at: Date.now(),
uploaded_at: null, uploaded_at: Date.now(),
}; };
insertAttachment(db, attachmentRecord); insertAttachment(db, attachmentRecord);
processAttachmentUpload(db, attachment.id, attachment.url, attachment.name || "unknown")
.then(() => {
if (broadcaster.broadcastAttachmentUploaded) { if (broadcaster.broadcastAttachmentUploaded) {
broadcaster.broadcastAttachmentUploaded({ broadcaster.broadcastAttachmentUploaded({
id: attachment.id, id: attachment.id,
@@ -79,13 +76,6 @@ export async function captureMessage(
created_at: Date.now(), created_at: Date.now(),
}); });
} }
})
.catch((error) => {
logger.error(
{ attachmentId: attachment.id, error: error instanceof Error ? error.message : String(error) },
"Background attachment upload failed",
);
});
} }
} }