Skip to content

Commit

Permalink
Merge pull request #1727 from matrix-org/nimau/6612-invite-email
Browse files Browse the repository at this point in the history
Direct room with a third party
  • Loading branch information
nimau authored Mar 1, 2023
2 parents 69e4dc3 + 6e702a6 commit cd68123
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
20 changes: 16 additions & 4 deletions MatrixSDK/Data/MXRoomSummaryUpdater.m
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,7 @@ - (BOOL)updateSummaryDisplayname:(MXRoomSummary *)summary session:(MXSession *)s
}
}

if (memberCount > 1
&& (!displayName || [displayName isEqualToString:_roomNameStringLocalizer.emptyRoom]))
if (!displayName || [displayName isEqualToString:_roomNameStringLocalizer.emptyRoom])
{
// Data are missing to compute the display name
MXLogDebug(@"[MXRoomSummaryUpdater] updateSummaryDisplayname: Warning: Computed an unexpected \"Empty Room\" name. memberCount: %@", @(memberCount));
Expand Down Expand Up @@ -565,10 +564,23 @@ - (NSString*)fixUnexpectedEmptyRoomDisplayname:(NSUInteger)memberCount session:(
switch (memberNames.count)
{
case 0:
MXLogDebug(@"[MXRoomSummaryUpdater] fixUnexpectedEmptyRoomDisplayname: No luck");
{
displayname = _roomNameStringLocalizer.emptyRoom;
NSString *directUserId = [session roomWithRoomId: roomState.roomId].directUserId;
if (directUserId != nil && [MXTools isEmailAddress:directUserId])
{
displayname = directUserId;
}
else if (roomState.thirdPartyInvites.firstObject.displayname != nil)
{
displayname = roomState.thirdPartyInvites.firstObject.displayname;
}
else
{
MXLogDebug(@"[MXRoomSummaryUpdater] fixUnexpectedEmptyRoomDisplayname: No luck");
}
break;

}
case 1:
if (memberCount == 2)
{
Expand Down
6 changes: 5 additions & 1 deletion MatrixSDK/MXSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -2509,8 +2509,12 @@ - (MXHTTPOperation*)createRoomWithParameters:(MXRoomCreationParameters*)paramete
{
// When the flag isDirect is turned on, only one user id is expected in the inviteArray.
// The room is considered as direct only for the first mentioned user in case of several user ids.
// Note: It is not possible FTM to mark as direct a room with an invited third party.
NSString *directUserId = (parameters.inviteArray.count ? parameters.inviteArray.firstObject : nil);
// Fall back on the first invite3PID address.
if (!directUserId && parameters.invite3PIDArray != nil && parameters.invite3PIDArray.count > 0)
{
directUserId = parameters.invite3PIDArray.firstObject.address;
}
[self onCreatedDirectChat:response withUserId:directUserId success:success];
}
else
Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-1727.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Creating a direct room with a third party will now use their email as the m.direct ID and their obfuscated email as the room title.

0 comments on commit cd68123

Please sign in to comment.