diff --git a/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m b/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m index 19fae141d2..7ae98184a3 100644 --- a/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m +++ b/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m @@ -833,35 +833,39 @@ - (NSAttributedString *)attributedStringFromEvent:(MXEvent*)event NSString *creatorId; MXJSONModelSetString(creatorId, event.content[@"creator"]); - if (creatorId) + if (!creatorId) { - if ([creatorId isEqualToString:mxSession.myUserId]) + // Room version 11 removes `creator` in favour of `sender`. + // https://github.com/matrix-org/matrix-spec-proposals/pull/2175 + creatorId = event.sender; + } + + if ([creatorId isEqualToString:mxSession.myUserId]) + { + if (isRoomDirect) { - if (isRoomDirect) - { - displayText = [VectorL10n noticeRoomCreatedByYouForDm]; - } - else - { - displayText = [VectorL10n noticeRoomCreatedByYou]; - } + displayText = [VectorL10n noticeRoomCreatedByYouForDm]; } else { - if (isRoomDirect) - { - displayText = [VectorL10n noticeRoomCreatedForDm:(roomState ? [roomState.members memberName:creatorId] : creatorId)]; - } - else - { - displayText = [VectorL10n noticeRoomCreated:(roomState ? [roomState.members memberName:creatorId] : creatorId)]; - } + displayText = [VectorL10n noticeRoomCreatedByYou]; } - // Append redacted info if any - if (redactedInfo) + } + else + { + if (isRoomDirect) { - displayText = [NSString stringWithFormat:@"%@ %@", displayText, redactedInfo]; + displayText = [VectorL10n noticeRoomCreatedForDm:(roomState ? [roomState.members memberName:creatorId] : creatorId)]; } + else + { + displayText = [VectorL10n noticeRoomCreated:(roomState ? [roomState.members memberName:creatorId] : creatorId)]; + } + } + // Append redacted info if any + if (redactedInfo) + { + displayText = [NSString stringWithFormat:@"%@ %@", displayText, redactedInfo]; } break; } diff --git a/changelog.d/7633.bugfix b/changelog.d/7633.bugfix new file mode 100644 index 0000000000..b7345971eb --- /dev/null +++ b/changelog.d/7633.bugfix @@ -0,0 +1 @@ +Fix a crash when opening v11 rooms. \ No newline at end of file