From ac3525e6163e244d0ba2ddcb1561bb59d61ab417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Fri, 2 Aug 2024 10:12:47 +0200 Subject: [PATCH 1/2] Hide non-relevant conversation settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- NextcloudTalk/NCRoom.swift | 16 ++++++++++++++++ NextcloudTalk/RoomInfoTableViewController.m | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/NextcloudTalk/NCRoom.swift b/NextcloudTalk/NCRoom.swift index 98c3ccb79..36035b768 100644 --- a/NextcloudTalk/NCRoom.swift +++ b/NextcloudTalk/NCRoom.swift @@ -68,6 +68,22 @@ import Realm self.type != .changelog && self.type != .noteToSelf } + public var supportsMessageExpiration: Bool { + if self.type == .formerOneToOne || self.type == .changelog { + return false + } + + return self.isUserOwnerOrModerator && NCDatabaseManager.sharedInstance().serverHasTalkCapability(kCapabilityMessageExpiration) + } + + public var supportsBanning: Bool { + if self.type == .oneToOne || self.type == .formerOneToOne || self.type == .changelog || self.type == .noteToSelf { + return false + } + + return self.isUserOwnerOrModerator && NCDatabaseManager.sharedInstance().serverHasTalkCapability(kCapabilityBanV1) + } + public var isBreakoutRoom: Bool { return self.objectType == NCRoomObjectTypeRoom } diff --git a/NextcloudTalk/RoomInfoTableViewController.m b/NextcloudTalk/RoomInfoTableViewController.m index cb843e9e1..6d1addaa7 100644 --- a/NextcloudTalk/RoomInfoTableViewController.m +++ b/NextcloudTalk/RoomInfoTableViewController.m @@ -405,12 +405,12 @@ - (NSArray *)getConversationActions NSMutableArray *actions = [[NSMutableArray alloc] init]; // Message expiration action - if (_room.isUserOwnerOrModerator && [[NCDatabaseManager sharedInstance] serverHasTalkCapability:kCapabilityMessageExpiration]) { + if ([_room supportsMessageExpiration]) { [actions addObject:[NSNumber numberWithInt:kConversationActionMessageExpiration]]; } // Banning actors - if (_room.isUserOwnerOrModerator && [[NCDatabaseManager sharedInstance] serverHasTalkCapability:kCapabilityBanV1]) { + if ([_room supportsBanning]) { [actions addObject:[NSNumber numberWithInt:kConversationActionBannedActors]]; } From 0d86c74925c3bfc325d156447efed8f3a08f90b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Fri, 2 Aug 2024 12:37:34 +0200 Subject: [PATCH 2/2] Explicitly check for supported room types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- NextcloudTalk/NCRoom.swift | 10 ++++------ NextcloudTalk/RoomInfoTableViewController.m | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/NextcloudTalk/NCRoom.swift b/NextcloudTalk/NCRoom.swift index 36035b768..f4bf93c07 100644 --- a/NextcloudTalk/NCRoom.swift +++ b/NextcloudTalk/NCRoom.swift @@ -68,7 +68,7 @@ import Realm self.type != .changelog && self.type != .noteToSelf } - public var supportsMessageExpiration: Bool { + public var supportsMessageExpirationModeration: Bool { if self.type == .formerOneToOne || self.type == .changelog { return false } @@ -76,12 +76,10 @@ import Realm return self.isUserOwnerOrModerator && NCDatabaseManager.sharedInstance().serverHasTalkCapability(kCapabilityMessageExpiration) } - public var supportsBanning: Bool { - if self.type == .oneToOne || self.type == .formerOneToOne || self.type == .changelog || self.type == .noteToSelf { - return false - } + public var supportsBanningModeration: Bool { + let supportedType = self.type == .group || self.type == .public - return self.isUserOwnerOrModerator && NCDatabaseManager.sharedInstance().serverHasTalkCapability(kCapabilityBanV1) + return supportedType && self.canModerate && NCDatabaseManager.sharedInstance().serverHasTalkCapability(kCapabilityBanV1) } public var isBreakoutRoom: Bool { diff --git a/NextcloudTalk/RoomInfoTableViewController.m b/NextcloudTalk/RoomInfoTableViewController.m index 6d1addaa7..e3023bb24 100644 --- a/NextcloudTalk/RoomInfoTableViewController.m +++ b/NextcloudTalk/RoomInfoTableViewController.m @@ -405,12 +405,12 @@ - (NSArray *)getConversationActions NSMutableArray *actions = [[NSMutableArray alloc] init]; // Message expiration action - if ([_room supportsMessageExpiration]) { + if ([_room supportsMessageExpirationModeration]) { [actions addObject:[NSNumber numberWithInt:kConversationActionMessageExpiration]]; } // Banning actors - if ([_room supportsBanning]) { + if ([_room supportsBanningModeration]) { [actions addObject:[NSNumber numberWithInt:kConversationActionBannedActors]]; }