Merge pull request #4565 from matrix-org/matthew/invite-npe

Fix crash for broken invites
This commit is contained in:
Michael Telatynski 2020-05-11 17:12:38 +01:00 committed by GitHub
commit c2fea7d4d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1717,8 +1717,11 @@ export default createReactClass({
} else {
const myUserId = this.context.credentials.userId;
const myMember = this.state.room.getMember(myUserId);
const inviteEvent = myMember.events.member;
var inviterName = inviteEvent.sender ? inviteEvent.sender.name : inviteEvent.getSender();
const inviteEvent = myMember ? myMember.events.member : null;
let inviterName = _t("Unknown");
if (inviteEvent) {
inviterName = inviteEvent.sender ? inviteEvent.sender.name : inviteEvent.getSender();
}
// We deliberately don't try to peek into invites, even if we have permission to peek
// as they could be a spam vector.