From 31ee0886b55e895f0cec01c80dbfa0d450c0c220 Mon Sep 17 00:00:00 2001 From: Giom Foret Date: Wed, 18 Nov 2020 23:53:31 +0100 Subject: [PATCH 1/3] Bug Fix: [Room Preview] unexpected failure on join: "Not possible to join an empty room" #346 When the link is based on the room alias, we convert the room alias into a room id to check alias validity. Then we have to keep the alias to promote join by room alias instead of room id when an alias is available, in order to handle federated room. --- Riot/Model/Room/RoomPreviewData.h | 12 ++++++++++-- Riot/Model/Room/RoomPreviewData.m | 8 ++++---- Tchap/Modules/Home/HomeCoordinator.swift | 4 ++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Riot/Model/Room/RoomPreviewData.h b/Riot/Model/Room/RoomPreviewData.h index 1f17340323..f689b91026 100644 --- a/Riot/Model/Room/RoomPreviewData.h +++ b/Riot/Model/Room/RoomPreviewData.h @@ -77,10 +77,18 @@ Contructors. @param roomId the id of the room. - @param emailInvitationParams, in case of an email invitation link, the query parameters extracted from the link. + @param roomAlias the potential alias (we have keep it when it is available. It may be required to join federated room). @param mxSession the session to open the room preview with. */ -- (instancetype)initWithRoomId:(NSString*)roomId andSession:(MXSession*)mxSession; +- (instancetype)initWithRoomId:(NSString*)roomId roomAlias:(NSString*)roomAlias andSession:(MXSession*)mxSession; + +/** +Contructors. + +@param roomId the id of the room. +@param emailInvitationParams, in case of an email invitation link, the query parameters extracted from the link. +@param mxSession the session to open the room preview with. +*/ - (instancetype)initWithRoomId:(NSString*)roomId emailInvitationParams:(NSDictionary*)emailInvitationParams andSession:(MXSession*)mxSession; /** diff --git a/Riot/Model/Room/RoomPreviewData.m b/Riot/Model/Room/RoomPreviewData.m index c1501bfdd9..e05d7ee433 100644 --- a/Riot/Model/Room/RoomPreviewData.m +++ b/Riot/Model/Room/RoomPreviewData.m @@ -19,12 +19,13 @@ @implementation RoomPreviewData -- (instancetype)initWithRoomId:(NSString *)roomId andSession:(MXSession *)mxSession +- (instancetype)initWithRoomId:(NSString *)roomId roomAlias:(NSString*)roomAlias andSession:(MXSession *)mxSession { self = [super init]; if (self) { _roomId = roomId; + _roomCanonicalAlias = roomAlias; _mxSession = mxSession; _numJoinedMembers = -1; } @@ -33,7 +34,7 @@ - (instancetype)initWithRoomId:(NSString *)roomId andSession:(MXSession *)mxSess - (instancetype)initWithRoomId:(NSString *)roomId emailInvitationParams:(NSDictionary *)emailInvitationParams andSession:(MXSession *)mxSession { - self = [self initWithRoomId:roomId andSession:mxSession]; + self = [self initWithRoomId:roomId roomAlias:nil andSession:mxSession]; if (self) { _emailInvitation = [[RoomEmailInvitation alloc] initWithParams:emailInvitationParams]; @@ -47,14 +48,13 @@ - (instancetype)initWithRoomId:(NSString *)roomId emailInvitationParams:(NSDicti - (instancetype)initWithPublicRoom:(MXPublicRoom*)publicRoom andSession:(MXSession*)mxSession { - self = [self initWithRoomId:publicRoom.roomId andSession:mxSession]; + self = [self initWithRoomId:publicRoom.roomId roomAlias:publicRoom.canonicalAlias andSession:mxSession]; if (self) { // Report public room data _roomName = publicRoom.displayname; _roomAvatarUrl = publicRoom.avatarUrl; _roomTopic = publicRoom.topic; - _roomCanonicalAlias = publicRoom.canonicalAlias; _roomAliases = publicRoom.aliases; _numJoinedMembers = publicRoom.numJoinedMembers; diff --git a/Tchap/Modules/Home/HomeCoordinator.swift b/Tchap/Modules/Home/HomeCoordinator.swift index 0a9cd24a28..dc19145786 100644 --- a/Tchap/Modules/Home/HomeCoordinator.swift +++ b/Tchap/Modules/Home/HomeCoordinator.swift @@ -125,7 +125,7 @@ final class HomeCoordinator: NSObject, HomeCoordinatorType { switch response { case .success(let roomId): - let roomPreviewData: RoomPreviewData = RoomPreviewData(roomId: roomId, andSession: sself.session) + let roomPreviewData: RoomPreviewData = RoomPreviewData(roomId: roomId, roomAlias: roomIdOrAlias, andSession: sself.session) roomPreviewData.roomName = roomName != nil ? roomName : roomIdOrAlias sself.showRoomPreview(with: roomPreviewData, onEventID: eventID) @@ -143,7 +143,7 @@ final class HomeCoordinator: NSObject, HomeCoordinatorType { } } } else { - let roomPreviewData: RoomPreviewData = RoomPreviewData(roomId: roomIdOrAlias, andSession: self.session) + let roomPreviewData: RoomPreviewData = RoomPreviewData(roomId: roomIdOrAlias, roomAlias: nil, andSession: self.session) roomPreviewData.roomName = roomName != nil ? roomName : roomIdOrAlias self.showRoomPreview(with: roomPreviewData, onEventID: eventID) From 0e6428f4e681a7d02902d92f3d8957dbadfd9dd5 Mon Sep 17 00:00:00 2001 From: Giom Foret Date: Thu, 19 Nov 2020 00:23:23 +0100 Subject: [PATCH 2/3] Fix the error message displayed to the external users when they try to join a room by link whereas they were not invited yet Note the received error is then: errcode = "M_UNKNOWN"; error = "Not allowed to join this room" --- Tchap/Modules/RoomPreview/RoomPreviewCoordinator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tchap/Modules/RoomPreview/RoomPreviewCoordinator.swift b/Tchap/Modules/RoomPreview/RoomPreviewCoordinator.swift index 70b080126e..d7ec0ecff7 100644 --- a/Tchap/Modules/RoomPreview/RoomPreviewCoordinator.swift +++ b/Tchap/Modules/RoomPreview/RoomPreviewCoordinator.swift @@ -161,7 +161,7 @@ final class RoomPreviewCoordinator: NSObject, RoomPreviewCoordinatorType { // 'Error when trying to join an empty room should be more explicit' errorMessage = Bundle.mxk_localizedString(forKey: "room_error_join_failed_empty_room") } else { - errorMessage = message + errorMessage = TchapL10n.tchapRoomAccessUnauthorized } } else { errorMessage = TchapL10n.errorMessageDefault From 74c6529d063625611ea62306a5144832a81f7002 Mon Sep 17 00:00:00 2001 From: Giom Foret Date: Thu, 19 Nov 2020 13:51:16 +0100 Subject: [PATCH 3/3] version ++ --- TCHAP_CHANGES.rst | 7 +++++++ Tchap.xcodeproj/project.pbxproj | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/TCHAP_CHANGES.rst b/TCHAP_CHANGES.rst index 8fdf450f80..6d0385631d 100644 --- a/TCHAP_CHANGES.rst +++ b/TCHAP_CHANGES.rst @@ -1,3 +1,10 @@ +Changes in Tchap 1.1.0 (2020-11-19) +=================================================== + +Bug Fixes: + * [Room Preview] unexpected failure on join: "Not possible to join an empty room" #346 + * Wrong error message displayed to the external users when they try to join a room by link + Changes in Tchap 1.0.30 (2020-11-17) =================================================== diff --git a/Tchap.xcodeproj/project.pbxproj b/Tchap.xcodeproj/project.pbxproj index a4a72603d7..195d64b252 100644 --- a/Tchap.xcodeproj/project.pbxproj +++ b/Tchap.xcodeproj/project.pbxproj @@ -9379,7 +9379,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 1.0.30; + MARKETING_VERSION = 1.1.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -9431,7 +9431,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 1.0.30; + MARKETING_VERSION = 1.1.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule;