mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-04 06:58:20 +02:00
MESSENGER-5386 us17 invite federated users only if room is federated
This commit is contained in:
+72
-15
@@ -201,21 +201,24 @@ extension ContactsPickerViewModel: ContactsTableViewControllerDelegate {
|
||||
return
|
||||
}
|
||||
|
||||
// Check for user
|
||||
if MXTools.isMatrixUserIdentifier(contact.displayName) {
|
||||
let user = MXUser(userId: contact.displayName)
|
||||
coordinatorDelegate?.contactsPickerViewModelDidStartValidatingUser(self)
|
||||
user?.update(fromHomeserverOfMatrixSession: self.room.mxSession, success: { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.coordinatorDelegate?.contactsPickerViewModelDidEndValidatingUser(self)
|
||||
self.displayInvitePrompt(contact: contact)
|
||||
}, failure: { [weak self] error in
|
||||
guard let self = self else { return }
|
||||
self.coordinatorDelegate?.contactsPickerViewModelDidEndValidatingUser(self)
|
||||
self.displayInvitePrompt(contact: contact, isUnknownUser: true)
|
||||
})
|
||||
} else {
|
||||
displayInvitePrompt(contact: contact)
|
||||
// bwi: #5386
|
||||
if checkRoomFederationStatusForInvite(contact: contact) {
|
||||
// Check for user
|
||||
if MXTools.isMatrixUserIdentifier(contact.displayName) {
|
||||
let user = MXUser(userId: contact.displayName)
|
||||
coordinatorDelegate?.contactsPickerViewModelDidStartValidatingUser(self)
|
||||
user?.update(fromHomeserverOfMatrixSession: self.room.mxSession, success: { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.coordinatorDelegate?.contactsPickerViewModelDidEndValidatingUser(self)
|
||||
self.displayInvitePrompt(contact: contact)
|
||||
}, failure: { [weak self] error in
|
||||
guard let self = self else { return }
|
||||
self.coordinatorDelegate?.contactsPickerViewModelDidEndValidatingUser(self)
|
||||
self.displayInvitePrompt(contact: contact, isUnknownUser: true)
|
||||
})
|
||||
} else {
|
||||
displayInvitePrompt(contact: contact)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,4 +303,58 @@ extension ContactsPickerViewModel: ContactsTableViewControllerDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
bwi: #5386 show error msg if federation is not configured or deactivated for this room
|
||||
- if user is not federated -> display invite prompt
|
||||
- if user federated -> Check:
|
||||
- if server acl is configured and room is federated / serverACL = "*" -> display invite prompt
|
||||
- if server acl is configured and room is not federated -> show error prompt
|
||||
- if server acl is not configured -> show error prompt
|
||||
*/
|
||||
private func checkRoomFederationStatusForInvite(contact: MXKContact) -> Bool {
|
||||
var canInvite: Bool = false
|
||||
if BWIBuildSettings.shared.isFederationEnabled {
|
||||
if let identifieres = contact.matrixIdentifiers {
|
||||
if let identifiere = identifieres.first as? String {
|
||||
// Check if user is federated
|
||||
if room.isRoomMemberFederated(identifiere) {
|
||||
// Get current serverACL settings for room
|
||||
room.getCurrentRoomServerACLSettings { serverACL in
|
||||
if let serverACL = serverACL {
|
||||
if serverACL.elementsEqual("*") {
|
||||
// Federation is active
|
||||
canInvite = true
|
||||
} else {
|
||||
// Federation is deactivated
|
||||
self.coordinatorDelegate?.contactsPickerViewModel(self, display: BWIL10n.roomParticipantsInvitePromptFederationForRoomNotAllowedText, title: "", actions: [
|
||||
UIAlertAction(title: VectorL10n.ok, style: .cancel)
|
||||
])
|
||||
}
|
||||
} else {
|
||||
// ServerACL not configured
|
||||
self.coordinatorDelegate?.contactsPickerViewModel(self, display: BWIL10n.roomParticipantsInvitePromptServerAclForRoomNotConfiguredText, title: "", actions: [
|
||||
UIAlertAction(title: VectorL10n.ok, style: .cancel)
|
||||
])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
canInvite = true
|
||||
}
|
||||
} else {
|
||||
// Show error if federation cannot be determined
|
||||
coordinatorDelegate?.contactsPickerViewModel(self, display: BWIL10n.roomParticipantsInvitePromptServerAclLoadingErrorText, title: "", actions: [
|
||||
UIAlertAction(title: VectorL10n.ok, style: .cancel)
|
||||
])
|
||||
}
|
||||
} else {
|
||||
// Show error if federation cannot be determined
|
||||
coordinatorDelegate?.contactsPickerViewModel(self, display: BWIL10n.roomParticipantsInvitePromptServerAclLoadingErrorText, title: "", actions: [
|
||||
UIAlertAction(title: VectorL10n.ok, style: .cancel)
|
||||
])
|
||||
}
|
||||
} else {
|
||||
canInvite = true
|
||||
}
|
||||
return canInvite
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user