Skip to content
Extraits de code Groupes Projets
Non vérifiée Valider da91ea58 rédigé par Will Hunt's avatar Will Hunt Validation de GitHub
Parcourir les fichiers

Merge pull request #250 from Half-Shot/hs/allow-crap-image-events

Allow files missing `info`
parents 44013d53 d4d10c50
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -186,8 +186,9 @@ export class MatrixEventProcessor { ...@@ -186,8 +186,9 @@ export class MatrixEventProcessor {
} }
if (event.content.info == null) { if (event.content.info == null) {
log.info("Event was an attachment type but was missing a content.info"); // Fractal sends images without an info, which is technically allowed
return ""; // but super unhelpful: https://gitlab.gnome.org/World/fractal/issues/206
event.content.info = {size: 0};
} }
if (event.content.url == null) { if (event.content.url == null) {
......
...@@ -508,6 +508,7 @@ describe("MatrixEventProcessor", () => { ...@@ -508,6 +508,7 @@ describe("MatrixEventProcessor", () => {
}); });
}); });
describe("HandleAttachment", () => { describe("HandleAttachment", () => {
const SMALL_FILE = 200;
it("message without an attachment", () => { it("message without an attachment", () => {
const processor = createMatrixEventProcessor(); const processor = createMatrixEventProcessor();
return expect(processor.HandleAttachment({ return expect(processor.HandleAttachment({
...@@ -521,8 +522,14 @@ describe("MatrixEventProcessor", () => { ...@@ -521,8 +522,14 @@ describe("MatrixEventProcessor", () => {
return expect(processor.HandleAttachment({ return expect(processor.HandleAttachment({
content: { content: {
msgtype: "m.video", 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", () => { it("message without a url", () => {
const processor = createMatrixEventProcessor(); const processor = createMatrixEventProcessor();
...@@ -550,7 +557,6 @@ describe("MatrixEventProcessor", () => { ...@@ -550,7 +557,6 @@ describe("MatrixEventProcessor", () => {
}, mxClient)).to.eventually.eq("[filename.webm](https://localhost/8000000)"); }, mxClient)).to.eventually.eq("[filename.webm](https://localhost/8000000)");
}); });
it("message with a small info.size", () => { it("message with a small info.size", () => {
const SMALL_FILE = 200;
const processor = createMatrixEventProcessor(); const processor = createMatrixEventProcessor();
return expect(processor.HandleAttachment({ return expect(processor.HandleAttachment({
content: { content: {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter