Fix matrix media attachments (#12967) thanks @williamtwomey

Co-authored-by: Gustavo Madeira Santana @gumadeiras
This commit is contained in:
williamtwomey
2026-02-10 12:18:47 -06:00
committed by GitHub
parent 96c46ed612
commit 5fab11198d

View File

@@ -30,11 +30,13 @@ async function fetchMatrixMediaBuffer(params: {
// Use the client's download method which handles auth
try {
const result = await params.client.downloadContent(params.mxcUrl);
const buffer = result.data;
const raw = result.data ?? result;
const buffer = Buffer.isBuffer(raw) ? raw : Buffer.from(raw);
if (buffer.byteLength > params.maxBytes) {
throw new Error("Matrix media exceeds configured size limit");
}
return { buffer: Buffer.from(buffer) };
return { buffer, headerType: result.contentType };
} catch (err) {
throw new Error(`Matrix media download failed: ${String(err)}`, { cause: err });
}