Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct room with a third party #1727

Merged
merged 4 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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])
giomfo marked this conversation as resolved.
Show resolved Hide resolved
{
// 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.