Fix matrix media attachments (#12967) thanks @williamtwomey
Co-authored-by: Gustavo Madeira Santana @gumadeiras
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user