Merge pull request #4885 from matrix-org/travis/room-list/preview-crash-2

Add a null guard for message event previews
pull/21833/head
Travis Ralston 2020-07-02 16:25:30 -06:00 committed by GitHub
commit 8f3c8ba804
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -30,6 +30,8 @@ export class MessageEventPreview implements IPreview {
eventContent = event.getContent()['m.new_content'];
}
if (!eventContent || !eventContent['body']) return null; // invalid for our purposes
let body = (eventContent['body'] || '').trim();
const msgtype = eventContent['msgtype'];
if (!body || !msgtype) return null; // invalid event, no preview