MCPcopy Index your code
hub / github.com/AnswerOverflow/AnswerOverflow / updateAttachments

Function updateAttachments

packages/core/src/message-node.ts:69–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

67 set: parsed,
68 });
69 const updateAttachments = async () => {
70 const existingAttachments = await db
71 .select()
72 .from(dbAttachments)
73 .where(eq(dbAttachments.messageId, msg.id));
74 const existingAttachmentIds = new Set(existingAttachments.map((a) => a.id));
75
76 if (!attachments) {
77 await db.delete(dbAttachments).where(eq(dbAttachments.messageId, msg.id));
78 return;
79 }
80 for await (const attachment of attachments) {
81 if (!existingAttachmentIds.has(attachment.id)) {
82 void uploadFileFromUrl({
83 url: attachment.url,
84 id: attachment.id,
85 contentType: attachment.contentType ?? undefined,
86 filename: attachment.filename,
87 }).then(async (uploaded) => {
88 if (!uploaded) return;
89 await db.insert(dbAttachments).values(
90 attachmentSchema.parse({
91 ...attachment,
92 proxyUrl: `https://cdn.answeroverflow.com/${attachment.id}/${attachment.filename}`,
93 }),
94 );
95 });
96 }
97 }
98 };
99 const updateReactions = async () => {
100 await db.delete(dbReactions).where(eq(dbReactions.messageId, msg.id));
101 if (!reactions) return;

Callers 1

upsertMessageFunction · 0.85

Calls 2

uploadFileFromUrlFunction · 0.90
parseMethod · 0.45

Tested by

no test coverage detected