Don't crash when invited room doesn't have member state for the current room

This smells illegal, but nothing stops a server from sending that to us so we shouldn't crash.

BUG: 478903
This commit is contained in:
Tobias Fella
2023-12-22 23:24:16 +01:00
parent 4e141e05f0
commit a613baa148

View File

@@ -108,16 +108,14 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
return;
}
auto roomMemberEvent = currentState().get<RoomMemberEvent>(localUser()->id());
Q_ASSERT(roomMemberEvent);
const QString senderId = roomMemberEvent->senderId();
QImage avatar_image;
if (!user(senderId)->avatarUrl(this).isEmpty()) {
avatar_image = user(senderId)->avatar(128, this);
if (roomMemberEvent && !user(roomMemberEvent->senderId())->avatarUrl(this).isEmpty()) {
avatar_image = user(roomMemberEvent->senderId())->avatar(128, this);
} else {
qWarning() << "using this room's avatar";
avatar_image = avatar(128);
}
NotificationsManager::instance().postInviteNotification(this, displayNameForHtml(), htmlSafeMemberName(senderId), avatar_image);
NotificationsManager::instance().postInviteNotification(this, displayNameForHtml(), htmlSafeMemberName(roomMemberEvent->senderId()), avatar_image);
});
connect(this, &Room::changed, this, [this] {
Q_EMIT canEncryptRoomChanged();