From 161203d4458bb8a8aa779614571863f1c478155e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Mon, 20 Apr 2020 10:02:40 +0200 Subject: [PATCH 1/2] EventIndex: Filter out events that don't have a propper content value. (cherry picked from commit 6084c08f345fcdebf4302091f24d7b49ccaa143e) --- src/indexing/EventIndex.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/indexing/EventIndex.js b/src/indexing/EventIndex.js index e4e8f26031..c09fc73a58 100644 --- a/src/indexing/EventIndex.js +++ b/src/indexing/EventIndex.js @@ -275,6 +275,7 @@ export default class EventIndex extends EventEmitter { const validEventType = isUsefulType && !ev.isRedacted() && !ev.isDecryptionFailure(); let validMsgType = true; + let hasContentValue = true; if (ev.getType() === "m.room.message" && !ev.isRedacted()) { // Expand this if there are more invalid msgtypes. @@ -282,9 +283,15 @@ export default class EventIndex extends EventEmitter { if (!msgtype) validMsgType = false; else validMsgType = !msgtype.startsWith("m.key.verification"); + + if (!ev.getContent().body) hasContentValue = false + } else if (ev.getType() === "m.room.topic" && !ev.isRedacted()) { + if (!ev.getContent().topic) hasContentValue = false; + } else if (ev.getType() === "m.room.name" && !ev.isRedacted()) { + if (!ev.getContent().name) hasContentValue = false; } - return validEventType && validMsgType; + return validEventType && validMsgType && hasContentValue; } /** From 212c3ca46cb784998b18d3a12ed864e23565de63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Mon, 20 Apr 2020 10:10:16 +0200 Subject: [PATCH 2/2] EventIndex: Add a missing semicolon. (cherry picked from commit 3781bdc9758ddb54f9eacc6f56784b0d64d8ca01) --- src/indexing/EventIndex.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/indexing/EventIndex.js b/src/indexing/EventIndex.js index c09fc73a58..a6bbbb5f96 100644 --- a/src/indexing/EventIndex.js +++ b/src/indexing/EventIndex.js @@ -284,7 +284,7 @@ export default class EventIndex extends EventEmitter { if (!msgtype) validMsgType = false; else validMsgType = !msgtype.startsWith("m.key.verification"); - if (!ev.getContent().body) hasContentValue = false + if (!ev.getContent().body) hasContentValue = false; } else if (ev.getType() === "m.room.topic" && !ev.isRedacted()) { if (!ev.getContent().topic) hasContentValue = false; } else if (ev.getType() === "m.room.name" && !ev.isRedacted()) {