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

Add alias to public room creation #3450

Merged
merged 30 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
061a6ce
added the address section
Velin92 Oct 21, 2024
abbd1c9
Merge branch 'develop' of https://github.com/vector-im/element-x-ios …
Velin92 Oct 24, 2024
2bde9f8
updated code and strings
Velin92 Oct 24, 2024
860848c
syncing name and address
Velin92 Oct 24, 2024
045f1ca
improved code
Velin92 Oct 24, 2024
e63e1a3
added a way to reset the state
Velin92 Oct 24, 2024
d40022f
better documentation
Velin92 Oct 24, 2024
4ccc896
Merge branch 'develop' of https://github.com/vector-im/element-x-ios …
Velin92 Nov 4, 2024
cf5ede5
update strings
Velin92 Nov 4, 2024
465ef8c
Merge branch 'develop' of https://github.com/vector-im/element-x-ios …
Velin92 Nov 4, 2024
5e61df6
handling the alias
Velin92 Nov 5, 2024
b1b2bf3
alias error state
Velin92 Nov 5, 2024
dcd2b49
update strings
Velin92 Nov 5, 2024
3607863
error handling
Velin92 Nov 6, 2024
25553fd
improved the error handling
Velin92 Nov 6, 2024
cf26512
Merge branch 'develop' of https://github.com/vector-im/element-x-ios …
Velin92 Nov 6, 2024
2c2be08
new preview tests, even if they do not work well
Velin92 Nov 6, 2024
eb6a3ba
improved tests
Velin92 Nov 6, 2024
ac5123c
unit tests
Velin92 Nov 7, 2024
a68f2c0
Merge branch 'develop' of https://github.com/vector-im/element-x-ios …
Velin92 Nov 7, 2024
29a309f
Merge branch 'develop' of https://github.com/vector-im/element-x-ios …
Velin92 Nov 7, 2024
8c1c235
pr comments and using the correct value
Velin92 Nov 7, 2024
98ffd6f
fix
Velin92 Nov 7, 2024
1ccb19c
pr comments
Velin92 Nov 7, 2024
edeccb8
to improve safety and control of the FF
Velin92 Nov 7, 2024
5cf9fe0
Merge branch 'develop' of https://github.com/vector-im/element-x-ios …
Velin92 Nov 8, 2024
a450891
fixed a test
Velin92 Nov 8, 2024
a9e883b
updated tests
Velin92 Nov 8, 2024
fff9cdd
Merge branch 'develop' of https://github.com/vector-im/element-x-ios …
Velin92 Nov 8, 2024
01c7f3e
update SDK
Velin92 Nov 8, 2024
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
2 changes: 1 addition & 1 deletion ElementX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7858,7 +7858,7 @@
repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift";
requirement = {
kind = exactVersion;
version = 1.0.65;
version = 1.0.66;
};
};
701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/element-hq/matrix-rust-components-swift",
"state" : {
"revision" : "399cc70987856c73e24b8888ac1ecc0eecf1716b",
"version" : "1.0.65"
"revision" : "902979581ff4f35e54a83cd7c5c340745d6f0d0e",
"version" : "1.0.66"
}
},
{
Expand Down
12 changes: 7 additions & 5 deletions ElementX/Resources/Localizations/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,16 @@
"screen_advanced_settings_element_call_base_url" = "Custom Element Call base URL";
"screen_advanced_settings_element_call_base_url_description" = "Set a custom base URL for Element Call.";
"screen_advanced_settings_element_call_base_url_validation_error" = "Invalid URL, please make sure you include the protocol (http/https) and the correct address.";
"screen_create_room_room_access_section_anyone_option_description" = "Anyone can join this room";
"screen_create_room_room_access_section_anyone_option_title" = "Anyone";
"screen_create_room_room_access_section_header" = "Room Access";
"screen_create_room_room_access_section_knocking_option_description" = "Anyone can ask to join the room but an administrator or a moderator will have to accept the request";
"screen_create_room_room_access_section_knocking_option_title" = "Ask to join";
"screen_create_room_room_address_invalid_symbols_error_description" = "Some characters are not allowed. Only letters, digits and the following symbols are supported ! $ & ‘ ( ) * + / ; = ? @ [ ] - . _";
"screen_create_room_room_address_not_available_error_description" = "This room address already exists, please try editing the room address field or change the room name";
"screen_create_room_room_address_section_footer" = "In order for this room to be visible in the public room directory, you will need a room address.";
"screen_create_room_room_address_section_title" = "Room address";
"screen_create_room_room_visibility_section_title" = "Room visibility";
"screen_create_room_access_section_anyone_option_description" = "Anyone can join this room";
"screen_create_room_access_section_anyone_option_title" = "Anyone";
"screen_create_room_access_section_header" = "Room Access";
"screen_create_room_access_section_knocking_option_description" = "Anyone can ask to join the room but an administrator or a moderator will have to accept the request";
"screen_create_room_access_section_knocking_option_title" = "Ask to join";
"screen_join_room_cancel_knock_action" = "Cancel request";
"screen_join_room_cancel_knock_alert_confirmation" = "Yes, cancel";
"screen_join_room_cancel_knock_alert_description" = "Are you sure that you want to cancel your request to join this room?";
Expand Down
24 changes: 14 additions & 10 deletions ElementX/Sources/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1093,16 +1093,6 @@ internal enum L10n {
internal static var screenCreatePollQuestionHint: String { return L10n.tr("Localizable", "screen_create_poll_question_hint") }
/// Create Poll
internal static var screenCreatePollTitle: String { return L10n.tr("Localizable", "screen_create_poll_title") }
/// Anyone can join this room
internal static var screenCreateRoomAccessSectionAnyoneOptionDescription: String { return L10n.tr("Localizable", "screen_create_room_access_section_anyone_option_description") }
/// Anyone
internal static var screenCreateRoomAccessSectionAnyoneOptionTitle: String { return L10n.tr("Localizable", "screen_create_room_access_section_anyone_option_title") }
/// Room Access
internal static var screenCreateRoomAccessSectionHeader: String { return L10n.tr("Localizable", "screen_create_room_access_section_header") }
/// Anyone can ask to join the room but an administrator or a moderator will have to accept the request
internal static var screenCreateRoomAccessSectionKnockingOptionDescription: String { return L10n.tr("Localizable", "screen_create_room_access_section_knocking_option_description") }
/// Ask to join
internal static var screenCreateRoomAccessSectionKnockingOptionTitle: String { return L10n.tr("Localizable", "screen_create_room_access_section_knocking_option_title") }
/// New room
internal static var screenCreateRoomActionCreateRoom: String { return L10n.tr("Localizable", "screen_create_room_action_create_room") }
/// Invite people
Expand All @@ -1118,6 +1108,20 @@ internal enum L10n {
internal static var screenCreateRoomPublicOptionDescription: String { return L10n.tr("Localizable", "screen_create_room_public_option_description") }
/// Public room
internal static var screenCreateRoomPublicOptionTitle: String { return L10n.tr("Localizable", "screen_create_room_public_option_title") }
/// Anyone can join this room
internal static var screenCreateRoomRoomAccessSectionAnyoneOptionDescription: String { return L10n.tr("Localizable", "screen_create_room_room_access_section_anyone_option_description") }
/// Anyone
internal static var screenCreateRoomRoomAccessSectionAnyoneOptionTitle: String { return L10n.tr("Localizable", "screen_create_room_room_access_section_anyone_option_title") }
/// Room Access
internal static var screenCreateRoomRoomAccessSectionHeader: String { return L10n.tr("Localizable", "screen_create_room_room_access_section_header") }
/// Anyone can ask to join the room but an administrator or a moderator will have to accept the request
internal static var screenCreateRoomRoomAccessSectionKnockingOptionDescription: String { return L10n.tr("Localizable", "screen_create_room_room_access_section_knocking_option_description") }
/// Ask to join
internal static var screenCreateRoomRoomAccessSectionKnockingOptionTitle: String { return L10n.tr("Localizable", "screen_create_room_room_access_section_knocking_option_title") }
/// Some characters are not allowed. Only letters, digits and the following symbols are supported ! $ & ‘ ( ) * + / ; = ? @ [ ] - . _
internal static var screenCreateRoomRoomAddressInvalidSymbolsErrorDescription: String { return L10n.tr("Localizable", "screen_create_room_room_address_invalid_symbols_error_description") }
/// This room address already exists, please try editing the room address field or change the room name
internal static var screenCreateRoomRoomAddressNotAvailableErrorDescription: String { return L10n.tr("Localizable", "screen_create_room_room_address_not_available_error_description") }
/// In order for this room to be visible in the public room directory, you will need a room address.
internal static var screenCreateRoomRoomAddressSectionFooter: String { return L10n.tr("Localizable", "screen_create_room_room_address_section_footer") }
/// Room address
Expand Down
8 changes: 6 additions & 2 deletions ElementX/Sources/Mocks/ClientProxyMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import Combine
import Foundation

struct ClientProxyMockConfiguration {
var homeserver = ""
var userIDServerName: String?
var userID: String = RoomMemberProxyMock.mockMe.userID
var deviceID: String?
var roomSummaryProvider: RoomSummaryProviderProtocol? = RoomSummaryProviderMock(.init())
Expand All @@ -28,7 +30,8 @@ extension ClientProxyMock {
userID = configuration.userID
deviceID = configuration.deviceID

homeserver = ""
homeserver = configuration.homeserver
userIDServerName = configuration.userIDServerName

roomSummaryProvider = configuration.roomSummaryProvider
alternateRoomSummaryProvider = RoomSummaryProviderMock(.init())
Expand All @@ -52,13 +55,14 @@ extension ClientProxyMock {
canDeactivateAccount = false
directRoomForUserIDReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
createDirectRoomWithExpectedRoomNameReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
uploadMediaReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
loadUserDisplayNameReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
setUserDisplayNameReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
loadUserAvatarURLReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
setUserAvatarMediaReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
removeUserAvatarReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
isAliasAvailableReturnValue = .success(true)
logoutReturnValue = nil
searchUsersSearchTermLimitReturnValue = .success(.init(results: [], limited: false))
profileForReturnValue = .success(.init(userID: "@a:b.com", displayName: "Some user"))
Expand Down
118 changes: 94 additions & 24 deletions ElementX/Sources/Mocks/Generated/GeneratedMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2628,72 +2628,72 @@ class ClientProxyMock: ClientProxyProtocol {
}
//MARK: - createRoom

var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLUnderlyingCallsCount = 0
var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLCallsCount: Int {
var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartUnderlyingCallsCount = 0
var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartCallsCount: Int {
get {
if Thread.isMainThread {
return createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLUnderlyingCallsCount
return createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLUnderlyingCallsCount
returnValue = createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartUnderlyingCallsCount
}

return returnValue!
}
}
set {
if Thread.isMainThread {
createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLUnderlyingCallsCount = newValue
createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLUnderlyingCallsCount = newValue
createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartUnderlyingCallsCount = newValue
}
}
}
}
var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLCalled: Bool {
return createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLCallsCount > 0
var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartCalled: Bool {
return createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartCallsCount > 0
}
var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLReceivedArguments: (name: String, topic: String?, isRoomPrivate: Bool, isKnockingOnly: Bool, userIDs: [String], avatarURL: URL?)?
var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLReceivedInvocations: [(name: String, topic: String?, isRoomPrivate: Bool, isKnockingOnly: Bool, userIDs: [String], avatarURL: URL?)] = []
var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartReceivedArguments: (name: String, topic: String?, isRoomPrivate: Bool, isKnockingOnly: Bool, userIDs: [String], avatarURL: URL?, aliasLocalPart: String?)?
var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartReceivedInvocations: [(name: String, topic: String?, isRoomPrivate: Bool, isKnockingOnly: Bool, userIDs: [String], avatarURL: URL?, aliasLocalPart: String?)] = []

var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLUnderlyingReturnValue: Result<String, ClientProxyError>!
var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLReturnValue: Result<String, ClientProxyError>! {
var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartUnderlyingReturnValue: Result<String, ClientProxyError>!
var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartReturnValue: Result<String, ClientProxyError>! {
get {
if Thread.isMainThread {
return createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLUnderlyingReturnValue
return createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartUnderlyingReturnValue
} else {
var returnValue: Result<String, ClientProxyError>? = nil
DispatchQueue.main.sync {
returnValue = createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLUnderlyingReturnValue
returnValue = createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartUnderlyingReturnValue
}

return returnValue!
}
}
set {
if Thread.isMainThread {
createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLUnderlyingReturnValue = newValue
createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLUnderlyingReturnValue = newValue
createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartUnderlyingReturnValue = newValue
}
}
}
}
var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLClosure: ((String, String?, Bool, Bool, [String], URL?) async -> Result<String, ClientProxyError>)?
var createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartClosure: ((String, String?, Bool, Bool, [String], URL?, String?) async -> Result<String, ClientProxyError>)?

func createRoom(name: String, topic: String?, isRoomPrivate: Bool, isKnockingOnly: Bool, userIDs: [String], avatarURL: URL?) async -> Result<String, ClientProxyError> {
createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLCallsCount += 1
createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLReceivedArguments = (name: name, topic: topic, isRoomPrivate: isRoomPrivate, isKnockingOnly: isKnockingOnly, userIDs: userIDs, avatarURL: avatarURL)
func createRoom(name: String, topic: String?, isRoomPrivate: Bool, isKnockingOnly: Bool, userIDs: [String], avatarURL: URL?, aliasLocalPart: String?) async -> Result<String, ClientProxyError> {
createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartCallsCount += 1
createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartReceivedArguments = (name: name, topic: topic, isRoomPrivate: isRoomPrivate, isKnockingOnly: isKnockingOnly, userIDs: userIDs, avatarURL: avatarURL, aliasLocalPart: aliasLocalPart)
DispatchQueue.main.async {
self.createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLReceivedInvocations.append((name: name, topic: topic, isRoomPrivate: isRoomPrivate, isKnockingOnly: isKnockingOnly, userIDs: userIDs, avatarURL: avatarURL))
self.createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartReceivedInvocations.append((name: name, topic: topic, isRoomPrivate: isRoomPrivate, isKnockingOnly: isKnockingOnly, userIDs: userIDs, avatarURL: avatarURL, aliasLocalPart: aliasLocalPart))
}
if let createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLClosure = createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLClosure {
return await createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLClosure(name, topic, isRoomPrivate, isKnockingOnly, userIDs, avatarURL)
if let createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartClosure = createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartClosure {
return await createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartClosure(name, topic, isRoomPrivate, isKnockingOnly, userIDs, avatarURL, aliasLocalPart)
} else {
return createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLReturnValue
return createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartReturnValue
}
}
//MARK: - joinRoom
Expand Down Expand Up @@ -3973,6 +3973,76 @@ class ClientProxyMock: ClientProxyProtocol {
return resolveRoomAliasReturnValue
}
}
//MARK: - isAliasAvailable

var isAliasAvailableUnderlyingCallsCount = 0
var isAliasAvailableCallsCount: Int {
get {
if Thread.isMainThread {
return isAliasAvailableUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = isAliasAvailableUnderlyingCallsCount
}

return returnValue!
}
}
set {
if Thread.isMainThread {
isAliasAvailableUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
isAliasAvailableUnderlyingCallsCount = newValue
}
}
}
}
var isAliasAvailableCalled: Bool {
return isAliasAvailableCallsCount > 0
}
var isAliasAvailableReceivedAlias: String?
var isAliasAvailableReceivedInvocations: [String] = []

var isAliasAvailableUnderlyingReturnValue: Result<Bool, ClientProxyError>!
var isAliasAvailableReturnValue: Result<Bool, ClientProxyError>! {
get {
if Thread.isMainThread {
return isAliasAvailableUnderlyingReturnValue
} else {
var returnValue: Result<Bool, ClientProxyError>? = nil
DispatchQueue.main.sync {
returnValue = isAliasAvailableUnderlyingReturnValue
}

return returnValue!
}
}
set {
if Thread.isMainThread {
isAliasAvailableUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
isAliasAvailableUnderlyingReturnValue = newValue
}
}
}
}
var isAliasAvailableClosure: ((String) async -> Result<Bool, ClientProxyError>)?

func isAliasAvailable(_ alias: String) async -> Result<Bool, ClientProxyError> {
isAliasAvailableCallsCount += 1
isAliasAvailableReceivedAlias = alias
DispatchQueue.main.async {
self.isAliasAvailableReceivedInvocations.append(alias)
}
if let isAliasAvailableClosure = isAliasAvailableClosure {
return await isAliasAvailableClosure(alias)
} else {
return isAliasAvailableReturnValue
}
}
//MARK: - getElementWellKnown

var getElementWellKnownUnderlyingCallsCount = 0
Expand Down
Loading
Loading