mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 15:09:31 +02:00
add checks for federated flag for room
This commit is contained in:
@@ -318,23 +318,30 @@ extension ContactsPickerViewModel: ContactsTableViewControllerDelegate {
|
||||
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: "", title: BWIL10n.roomParticipantsInvitePromptFederationForRoomNotAllowedText, actions: [
|
||||
UIAlertAction(title: VectorL10n.ok, style: .cancel)
|
||||
])
|
||||
// Check if room federation flag "isFederated" is true
|
||||
room.getFederatedFlag { isFederated in
|
||||
if isFederated {
|
||||
// Get current serverACL settings for room
|
||||
self.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: "", title: BWIL10n.roomParticipantsInvitePromptFederationForRoomNotAllowedText, actions:
|
||||
[UIAlertAction(title: VectorL10n.ok, style: .cancel)])
|
||||
}
|
||||
} else {
|
||||
// ServerACL not configured
|
||||
self.coordinatorDelegate?.contactsPickerViewModel(self, display: "", title: BWIL10n.roomParticipantsInvitePromptServerAclForRoomNotConfiguredText, actions:
|
||||
[UIAlertAction(title: VectorL10n.ok, style: .cancel)])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// ServerACL not configured
|
||||
self.coordinatorDelegate?.contactsPickerViewModel(self, display: "", title: BWIL10n.roomParticipantsInvitePromptServerAclForRoomNotConfiguredText, actions: [
|
||||
UIAlertAction(title: VectorL10n.ok, style: .cancel)
|
||||
])
|
||||
// Federation is deactivated
|
||||
self.coordinatorDelegate?.contactsPickerViewModel(self, display: "", title: BWIL10n.roomParticipantsInvitePromptFederationForRoomNotAllowedText, actions:
|
||||
[UIAlertAction(title: VectorL10n.ok, style: .cancel)])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -8257,35 +8257,37 @@ static CGSize kThreadListBarButtonItemImageSize;
|
||||
if (!self.roomDataSource.room.isPersonalNotesRoom)
|
||||
{
|
||||
// Do not show sheet if isFederated room flag is false (default == true)
|
||||
if (self.roomDataSource.room.isRoomFederated)
|
||||
{
|
||||
// Do not show sheet if users power level is lower than admin
|
||||
MXRoomPowerLevels *powerLevels = self.roomDataSource.roomState.powerLevels;
|
||||
if ([powerLevels powerLevelOfUserWithUserID:self.mainSession.myUser.userId] >= RoomPowerLevelAdmin)
|
||||
[self.roomDataSource.room getFederatedFlagWithCompletion:^(BOOL isFederated) {
|
||||
if (isFederated)
|
||||
{
|
||||
// Show sheet if no serverACL have been configured
|
||||
[self.roomDataSource.room getCurrentRoomServerACLSettingsWithCompletion:^(NSString *serverACL)
|
||||
{
|
||||
if (serverACL == nil) {
|
||||
self.wasFederationDecisionSheetShownBefore = true;
|
||||
RoomFederationDecisionSheet *federationDecisionView = [[RoomFederationDecisionSheet alloc] init];
|
||||
UIImage *roomAvatarImage;
|
||||
MXKImageView *roomAvatarImageView = ((RoomTitleView*)self.titleView).pictureView;
|
||||
if (roomAvatarImageView && roomAvatarImageView.image)
|
||||
{
|
||||
roomAvatarImage = roomAvatarImageView.image;
|
||||
// Do not show sheet if users power level is lower than admin
|
||||
MXRoomPowerLevels *powerLevels = self.roomDataSource.roomState.powerLevels;
|
||||
if ([powerLevels powerLevelOfUserWithUserID:self.mainSession.myUser.userId] >= RoomPowerLevelAdmin)
|
||||
{
|
||||
// Show sheet if no serverACL have been configured
|
||||
[self.roomDataSource.room getCurrentRoomServerACLSettingsWithCompletion:^(NSString *serverACL)
|
||||
{
|
||||
if (serverACL == nil) {
|
||||
self.wasFederationDecisionSheetShownBefore = true;
|
||||
RoomFederationDecisionSheet *federationDecisionView = [[RoomFederationDecisionSheet alloc] init];
|
||||
UIImage *roomAvatarImage;
|
||||
MXKImageView *roomAvatarImageView = ((RoomTitleView*)self.titleView).pictureView;
|
||||
if (roomAvatarImageView && roomAvatarImageView.image)
|
||||
{
|
||||
roomAvatarImage = roomAvatarImageView.image;
|
||||
}
|
||||
else
|
||||
{
|
||||
roomAvatarImage = [AvatarGenerator generateAvatarForMatrixItem:self.roomDataSource.roomId withDisplayName:self.roomDataSource.room.summary.displayName];
|
||||
}
|
||||
UIViewController *sheetViewController = [federationDecisionView makeViewControllerWithRoom:self.roomDataSource.room roomAvatarImage: roomAvatarImage];
|
||||
sheetViewController.modalPresentationStyle = UIModalPresentationFormSheet;
|
||||
[self presentViewController:sheetViewController animated:YES completion:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
roomAvatarImage = [AvatarGenerator generateAvatarForMatrixItem:self.roomDataSource.roomId withDisplayName:self.roomDataSource.room.summary.displayName];
|
||||
}
|
||||
UIViewController *sheetViewController = [federationDecisionView makeViewControllerWithRoom:self.roomDataSource.room roomAvatarImage: roomAvatarImage];
|
||||
sheetViewController.modalPresentationStyle = UIModalPresentationFormSheet;
|
||||
[self presentViewController:sheetViewController animated:YES completion:nil];
|
||||
}
|
||||
}];
|
||||
}];
|
||||
}
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user