diff --git a/src/matrixeventprocessor.ts b/src/matrixeventprocessor.ts index a9e68588602cb3f81b16d17bf65b40cf4b16a18c..1ec23a3074f74e723b7400b3179eb859e9dc8e72 100644 --- a/src/matrixeventprocessor.ts +++ b/src/matrixeventprocessor.ts @@ -186,8 +186,9 @@ export class MatrixEventProcessor { } if (event.content.info == null) { - log.info("Event was an attachment type but was missing a content.info"); - return ""; + // Fractal sends images without an info, which is technically allowed + // but super unhelpful: https://gitlab.gnome.org/World/fractal/issues/206 + event.content.info = {size: 0}; } if (event.content.url == null) { diff --git a/test/test_matrixeventprocessor.ts b/test/test_matrixeventprocessor.ts index c778d20af42eb07506d9f4c77a0f5813cdbc9cd2..50764af2a68d9e29a76f9ae7b036a89aabf0fdc2 100644 --- a/test/test_matrixeventprocessor.ts +++ b/test/test_matrixeventprocessor.ts @@ -508,6 +508,7 @@ describe("MatrixEventProcessor", () => { }); }); describe("HandleAttachment", () => { + const SMALL_FILE = 200; it("message without an attachment", () => { const processor = createMatrixEventProcessor(); return expect(processor.HandleAttachment({ @@ -521,8 +522,14 @@ describe("MatrixEventProcessor", () => { return expect(processor.HandleAttachment({ content: { msgtype: "m.video", + body: "filename.webm", + url: "mxc://localhost/200", }, - }, mxClient)).to.eventually.eq(""); + }, mxClient)).to.eventually.satisfy((attachment) => { + expect(attachment.name).to.eq("filename.webm"); + expect(attachment.attachment.length).to.eq(SMALL_FILE); + return true; + }); }); it("message without a url", () => { const processor = createMatrixEventProcessor(); @@ -550,7 +557,6 @@ describe("MatrixEventProcessor", () => { }, mxClient)).to.eventually.eq("[filename.webm](https://localhost/8000000)"); }); it("message with a small info.size", () => { - const SMALL_FILE = 200; const processor = createMatrixEventProcessor(); return expect(processor.HandleAttachment({ content: {