Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions Riot/Assets/en.lproj/Untranslated.strings
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
// MARK: Onboarding Personalization WIP

"image_picker_action_files" = "Choose from files";
"voice_broadcast_in_timeline_title" = "Voice broadcast detected (under active development)";
"room_settings_advanced_incognito_title" = "Enable Incognito Mode";

4 changes: 4 additions & 0 deletions Riot/Categories/MXRoom+Riot.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,8 @@
*/
- (void)encryptionTrustLevelForUserId:(NSString*)userId onComplete:(void (^)(UserEncryptionTrustLevel userEncryptionTrustLevel))onComplete;

// Returns bool value if the room incognito mode enabled by admin.

+ (BOOL)isRoomIncognitoEnabled:(MXRoomState*)roomState;

@end
13 changes: 13 additions & 0 deletions Riot/Categories/MXRoom+Riot.m
Original file line number Diff line number Diff line change
Expand Up @@ -660,4 +660,17 @@ - (id)notificationCenterDidUpdateObserver
return objc_getAssociatedObject(self, @selector(notificationCenterDidUpdateObserver));
}

+ (BOOL)isRoomIncognitoEnabled:(MXRoomState*)roomState {

NSPredicate *customPolicy = [NSPredicate predicateWithFormat:@"type like %@", @"m.room.custom.policy"];
NSArray<MXEvent*> *events = [roomState.stateEvents filteredArrayUsingPredicate:customPolicy];
NSArray *sortedArray = [events sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
return [[obj1 valueForKey:@"originServerTs"] compare:[obj2 valueForKey:@"originServerTs"]];
}];
MXEvent *event = sortedArray.lastObject;
NSString *incognitoMode = [[event wireContent]
valueForKey:@"incognito"];
return [incognitoMode isEqualToString:@"incognito.enabled"];
}

@end
8 changes: 8 additions & 0 deletions Riot/Generated/UntranslatedStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ public extension VectorL10n {
static var imagePickerActionFiles: String {
return VectorL10n.tr("Untranslated", "image_picker_action_files")
}
/// Enable Incognito Mode
static var roomSettingsAdvancedIncognitoTitle: String {
return VectorL10n.tr("Untranslated", "room_settings_advanced_incognito_title")
}
/// Voice broadcast detected (under active development)
static var voiceBroadcastInTimelineTitle: String {
return VectorL10n.tr("Untranslated", "voice_broadcast_in_timeline_title")
}
}
// swiftlint:enable function_parameter_count identifier_name line_length type_body_length

22 changes: 22 additions & 0 deletions Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#import "MXEvent+MatrixKit.h"
#import "MXKSwiftHeader.h"
#import <MatrixSDK/MatrixSDK.h>
#import "MXRoom+Riot.h"

@interface MXKRoomBubbleComponent ()

Expand All @@ -45,6 +46,27 @@ - (instancetype)initWithEvent:(MXEvent*)event
andLatestRoomState:latestRoomState
error:&error];

if ([MXRoom isRoomIncognitoEnabled:roomState]) {
NSArray *excludedEvents = @[
@(MXEventTypeRoomMember),
@(MXEventTypeRoomJoinRules),
@(MXEventTypeRoomPowerLevels),
@(MXEventTypeRoomHistoryVisibility),
@(MXEventTypeRoomRedaction),
@(MXEventTypeRoomThirdPartyInvite)];

if ([excludedEvents containsObject:@(event.eventType)]) {
return nil;
}

if (event.wireEventType == MXEventTypeRoomMember) {
if ([event.wireContent valueForKey:@"membership"]) {
return nil;
}

}
}

// Store the potential error
event.mxkEventFormatterError = error;

Expand Down
2 changes: 1 addition & 1 deletion Riot/Modules/Room/DataSources/RoomDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}

// Check whether some receipts are found
if (roomMembers.count)
if (roomMembers.count && ![MXRoom isRoomIncognitoEnabled:self.roomState])
{
// Define the read receipts container, positioned on the right border of the bubble cell (Note the right margin 6 pts).
avatarsContainer = [[MXKReceiptSendersContainer alloc] initWithFrame:CGRectMake(bubbleCell.frame.size.width - PlainRoomCellLayoutConstants.readReceiptsViewWidth + PlainRoomCellLayoutConstants.readReceiptsViewRightMargin, bottomPositionY + PlainRoomCellLayoutConstants.readReceiptsViewTopMargin, PlainRoomCellLayoutConstants.readReceiptsViewWidth, PlainRoomCellLayoutConstants.readReceiptsViewHeight) andMediaManager:self.mxSession.mediaManager];
Expand Down
11 changes: 10 additions & 1 deletion Riot/Modules/Room/Members/RoomParticipantsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#import "ContactTableViewCell.h"

#import "RageShakeManager.h"
#import "MXRoom+Riot.h"

@interface RoomParticipantsViewController () <UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate, UIGestureRecognizerDelegate, MXKRoomMemberDetailsViewControllerDelegate, RoomParticipantsInviteCoordinatorBridgePresenterDelegate>
{
Expand Down Expand Up @@ -856,7 +857,15 @@ - (void)showDetailFor:(MXRoomMember* _Nonnull)member from:(UIView* _Nullable)sou
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
NSInteger count = 0;

MXRoomState *roomState = self.mxRoom.dangerousSyncState;
// If the room is incognito mode non admin users can't see the list of members
if([MXRoom isRoomIncognitoEnabled:roomState]) {
MXRoomPowerLevels *powerLevels = [roomState powerLevels];
NSInteger oneSelfPowerLevel = [powerLevels powerLevelOfUserWithUserID:self.mainSession.myUser.userId];
if(oneSelfPowerLevel < RoomPowerLevelModerator) {
return 0;
}
}
participantsSection = invitedSection = -1;

if (currentSearchText.length)
Expand Down
69 changes: 68 additions & 1 deletion Riot/Modules/Room/Settings/RoomSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#import "RoomMemberDetailsViewController.h"

#import <MobileCoreServices/MobileCoreServices.h>
#import "MXRoom+Riot.h"

enum
{
Expand Down Expand Up @@ -82,7 +83,8 @@
ROOM_SETTINGS_ADVANCED_ENCRYPT_TO_VERIFIED,
ROOM_SETTINGS_ADVANCED_ENCRYPTION_ENABLED,
ROOM_SETTINGS_ADVANCED_ENABLE_ENCRYPTION,
ROOM_SETTINGS_ADVANCED_ENCRYPTION_DISABLED
ROOM_SETTINGS_ADVANCED_ENCRYPTION_DISABLED,
ROOM_SETTINGS_ADVANCED_INCOGNITO
};

enum
Expand Down Expand Up @@ -120,6 +122,9 @@
NSString *const kRoomSettingsAdvancedEnableE2eCellViewIdentifier = @"kRoomSettingsAdvancedEnableE2eCellViewIdentifier";
NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSettingsAdvancedE2eEnabledCellViewIdentifier";

NSString *const kRoomSettingsAdvancedIncognito = @"kRoomSettingsAdvancedIncognito";


@interface RoomSettingsViewController () <SingleImagePickerPresenterDelegate, TableViewSectionsDelegate, RoomAccessCoordinatorBridgePresenterDelegate, RoomSuggestionCoordinatorBridgePresenterDelegate>
{
// The updated user data
Expand Down Expand Up @@ -605,6 +610,7 @@ - (void)updateSections
Section *sectionAdvanced = [Section sectionWithTag:SECTION_TAG_BANNED_ADVANCED];

[sectionAdvanced addRowWithTag:ROOM_SETTINGS_ADVANCED_ROOM_ID];
[sectionAdvanced addRowWithTag:ROOM_SETTINGS_ADVANCED_INCOGNITO];
if (mxRoom.mxSession.crypto)
{
if (mxRoom.summary.isEncrypted)
Expand Down Expand Up @@ -2018,6 +2024,43 @@ - (IBAction)onSave:(id)sender
BOOL blacklistUnverifiedDevices = [((NSNumber*)updatedItemsDict[kRoomSettingsEncryptionBlacklistUnverifiedDevicesKey]) boolValue];
[mxRoom.mxSession.crypto setBlacklistUnverifiedDevicesInRoom:mxRoom.roomId blacklist:blacklistUnverifiedDevices];
}

if(updatedItemsDict[kRoomSettingsAdvancedIncognito]) {
BOOL enableIncognito = [((NSNumber*)updatedItemsDict[kRoomSettingsAdvancedIncognito]) boolValue];

// m.room.custom.policy will be stored with key incognito and value incognito.enabled to enable the incognito mode
[mxRoom sendStateEventOfType:@"m.room.custom.policy"
content:@{@"incognito" : enableIncognito ? @"incognito.enabled" : @"incognito.disabled"}
stateKey:nil
success:^(NSString *eventId) {
if (weakSelf)
{
typeof(self) self = weakSelf;
[self->updatedItemsDict removeObjectForKey:kRoomSettingsAdvancedIncognito];
[self onSave:nil];
}

} failure:^(NSError *error) {
MXLogDebug(@"[RoomSettingsViewController] Update incognito failed");
if (weakSelf)
{
typeof(self) self = weakSelf;
self->pendingOperation = nil;

dispatch_async(dispatch_get_main_queue(), ^{
NSString* message = error.localizedDescription;
if (!message.length)
{
message = @"Failed to update incoginto";
}
[self onSaveFailed:message withKeys:@[kRoomSettingsAdvancedIncognito]];

});
}

}
];
}
}

[self getNavigationItem].rightBarButtonItem.enabled = NO;
Expand Down Expand Up @@ -2798,6 +2841,16 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
else if (row == ROOM_SETTINGS_ADVANCED_INCOGNITO)
{
MXKTableViewCellWithLabelAndSwitch *roomIncognitoModeCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
[roomIncognitoModeCell.mxkSwitch addTarget:self action:@selector(toggleIncognitoMode:) forControlEvents:UIControlEventValueChanged];
roomIncognitoModeCell.mxkSwitch.onTintColor = ThemeService.shared.theme.tintColor;
roomIncognitoModeCell.mxkSwitch.on = [MXRoom isRoomIncognitoEnabled:mxRoomState];
roomIncognitoModeCell.mxkLabel.text = [VectorL10n roomSettingsAdvancedIncognitoTitle];
cell = roomIncognitoModeCell;
cell.userInteractionEnabled = oneSelfPowerLevel == RoomPowerLevelAdmin;
}
}

// Sanity check
Expand Down Expand Up @@ -3387,6 +3440,20 @@ - (void)toggleBlacklistUnverifiedDevice:(UISwitch*)theSwitch
[self getNavigationItem].rightBarButtonItem.enabled = (updatedItemsDict.count != 0);
}

- (void)toggleIncognitoMode:(UISwitch*)theSwitch
{

if ([MXRoom isRoomIncognitoEnabled:mxRoomState] != theSwitch.on)
{
updatedItemsDict[kRoomSettingsAdvancedIncognito] = @(theSwitch.on);
}
else
{
[updatedItemsDict removeObjectForKey:kRoomSettingsAdvancedIncognito];
}

[self getNavigationItem].rightBarButtonItem.enabled = (updatedItemsDict.count != 0);
}

- (void)toggleDirectoryVisibility:(UISwitch*)theSwitch
{
Expand Down
1 change: 1 addition & 0 deletions changelog.d/6989.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Incognito mode for large rooms like announcements room #6989