diff --git a/MatrixSDK/Crypto/Data/MXDeviceList.h b/MatrixSDK/Crypto/Data/MXDeviceList.h index 077b6b2f5a..c5ef3daa8c 100644 --- a/MatrixSDK/Crypto/Data/MXDeviceList.h +++ b/MatrixSDK/Crypto/Data/MXDeviceList.h @@ -27,6 +27,16 @@ @class MXCrypto; +// Constants for DeviceList.deviceTrackingStatus +typedef enum : NSUInteger +{ + MXDeviceTrackingStatusNotTracked = 0, + MXDeviceTrackingStatusPendingDownload, + MXDeviceTrackingStatusDownloadInProgress, + MXDeviceTrackingStatusUpToDate + +} MXDeviceTrackingStatus; + /** `MXDeviceList` manages the list of other users' devices. */ @@ -78,8 +88,22 @@ */ - (MXDeviceInfo*)deviceWithIdentityKey:(NSString*)senderKey forUser:(NSString*)userId andAlgorithm:(NSString*)algorithm; +/** + Flag the given user for device-list tracking, if they are not already. + + This will mean that a subsequent call to refreshOutdatedDeviceLists + will download the device list for the user, and that subsequent calls to + invalidateUserDeviceList will trigger more updates. + + @param userId. + */ +- (void)startTrackingDeviceList:(NSString*)userId; + /** Mark the cached device list for the given user outdated. + + If we are not tracking this user's devices, we'll do nothing. Otherwise + we flag the user as needing an update. This doesn't set off an update, so that several users can be batched together. Call refreshOutdatedDeviceLists for that. @@ -89,8 +113,15 @@ - (void)invalidateUserDeviceList:(NSString*)userId; /** - If there is not already a device list query in progress, and we have - users who have outdated device lists, start a query now. + Mark all tracked device lists as outdated. + + This will flag each user whose devices we are tracking as in need of an + update. + */ +- (void)invalidateAllDeviceLists; + +/** + If we have users who have outdated device lists, start key downloads for them. */ - (void)refreshOutdatedDeviceLists; diff --git a/MatrixSDK/Crypto/Data/MXDeviceList.m b/MatrixSDK/Crypto/Data/MXDeviceList.m index d68d5137de..a0b4a49b87 100644 --- a/MatrixSDK/Crypto/Data/MXDeviceList.m +++ b/MatrixSDK/Crypto/Data/MXDeviceList.m @@ -22,12 +22,17 @@ #import "MXDeviceListOperationsPool.h" +// Helper to transform a NSNumber stored in a NSDictionary to MXDeviceTrackingStatus +#define MXDeviceTrackingStatusFromNSNumber(aNSNumberObject) ((MXDeviceTrackingStatus)[aNSNumberObject integerValue]) + + @interface MXDeviceList () { MXCrypto *crypto; - // Users with new devices - NSMutableSet *pendingUsersWithNewDevices; + // Users we are tracking device status for. + // userId -> MXDeviceTrackingStatus* + NSMutableDictionary *deviceTrackingStatus; /** The pool which the http request is currenlty being processed. @@ -57,7 +62,17 @@ - (id)initWithCrypto:(MXCrypto *)theCrypto { crypto = theCrypto; - pendingUsersWithNewDevices = [NSMutableSet set]; + // Retrieve tracking status from the store + deviceTrackingStatus = [NSMutableDictionary dictionaryWithDictionary:[crypto.store deviceTrackingStatus]]; + + for (NSString *userId in deviceTrackingStatus) + { + // if a download was in progress when we got shut down, it isn't any more. + if (MXDeviceTrackingStatusFromNSNumber(deviceTrackingStatus[userId]) == MXDeviceTrackingStatusDownloadInProgress) + { + deviceTrackingStatus[userId] = @(MXDeviceTrackingStatusPendingDownload); + } + } } return self; } @@ -68,64 +83,52 @@ - (MXHTTPOperation*)downloadKeys:(NSArray*)userIds forceDownload:(BOO { NSLog(@"[MXDeviceList] downloadKeys(forceDownload: %tu) : %@", forceDownload, userIds); - BOOL needsRefresh = NO; - BOOL waitForCurrentQuery = NO; + NSMutableArray *usersToDownload = [NSMutableArray array]; + BOOL doANewQuery = NO; for (NSString *userId in userIds) { - if ([pendingUsersWithNewDevices containsObject:userId]) - { - // we already know this user's devices are outdated - needsRefresh = YES; - } - else if ([currentQueryPool.userIds containsObject:userId]) - { - // already a download in progress - just wait for it. - // (even if forceDownload is true) - waitForCurrentQuery = true; - } - else if (forceDownload) + MXDeviceTrackingStatus trackingStatus = MXDeviceTrackingStatusFromNSNumber(deviceTrackingStatus[userId]); + + if ([currentQueryPool.userIds containsObject:userId]) // equivalent to (trackingStatus == MXDeviceTrackingStatusDownloadInProgress) { - NSLog(@"[MXDeviceList] downloadKeys: Invalidating device list for %@ for forceDownload", userId); - [self invalidateUserDeviceList:userId]; - needsRefresh = true; + // already a key download in progress/queued for this user; its results + // will be good enough for us. + [usersToDownload addObject:userId]; } - else if (![self storedDevicesForUser:userId]) + else if (forceDownload || trackingStatus != MXDeviceTrackingStatusUpToDate) { - NSLog(@"[MXDeviceList] downloadKeys: Invalidating device list for %@ due to empty cache", userId); - [self invalidateUserDeviceList:userId]; - needsRefresh = true; + [usersToDownload addObject:userId]; + doANewQuery = YES; } } MXDeviceListOperation *operation; - if (needsRefresh) + if (usersToDownload.count) { - NSLog(@"[MXDeviceList] downloadKeys: waiting for next key query"); + for (NSString *userId in usersToDownload) + { + deviceTrackingStatus[userId] = @(MXDeviceTrackingStatusDownloadInProgress); + } - operation = [[MXDeviceListOperation alloc] initWithUserIds:userIds success:^(NSArray *succeededUserIds, NSArray *failedUserIds) { + operation = [[MXDeviceListOperation alloc] initWithUserIds:usersToDownload success:^(NSArray *succeededUserIds, NSArray *failedUserIds) { - NSLog(@"[MXDeviceList] downloadKeys: waiting for next key query -> DONE"); - if (success) + NSLog(@"[MXDeviceList] downloadKeys -> DONE"); + + for (NSString *userId in succeededUserIds) { - MXUsersDevicesMap *usersDevicesInfoMap = [self devicesForUsers:userIds]; - success(usersDevicesInfoMap); + MXDeviceTrackingStatus trackingStatus = MXDeviceTrackingStatusFromNSNumber(deviceTrackingStatus[userId]); + if (trackingStatus == MXDeviceTrackingStatusDownloadInProgress) + { + // we didn't get any new invalidations since this download started: + // this user's device list is now up to date. + deviceTrackingStatus[userId] = @(MXDeviceTrackingStatusUpToDate); + } } - } failure:failure]; - - [self startOrQueueDeviceQuery:operation]; - - return operation; - } - else if (waitForCurrentQuery) - { - NSLog(@"[MXDeviceList] downloadKeys: waiting for in-flight query to complete"); + [self persistDeviceTrackingStatus]; - operation = [[MXDeviceListOperation alloc] initWithUserIds:userIds success:^(NSArray *succeededUserIds, NSArray *failedUserIds) { - - NSLog(@"[MXDeviceList] downloadKeys: waiting for in-flight query to complete -> DONE"); if (success) { MXUsersDevicesMap *usersDevicesInfoMap = [self devicesForUsers:userIds]; @@ -134,9 +137,19 @@ - (MXHTTPOperation*)downloadKeys:(NSArray*)userIds forceDownload:(BOO } failure:failure]; - [operation addToPool:currentQueryPool]; + if (doANewQuery) + { + NSLog(@"[MXDeviceList] downloadKeys: waiting for next key query"); - return operation; + [self startOrQueueDeviceQuery:operation]; + } + else + { + + NSLog(@"[MXDeviceList] downloadKeys: waiting for in-flight query to complete"); + + [operation addToPool:currentQueryPool]; + } } else { @@ -182,24 +195,60 @@ - (MXDeviceInfo *)deviceWithIdentityKey:(NSString *)senderKey forUser:(NSString return nil; } +- (void)startTrackingDeviceList:(NSString*)userId +{ + MXDeviceTrackingStatus trackingStatus = MXDeviceTrackingStatusFromNSNumber(deviceTrackingStatus[userId]); + + if (!trackingStatus) + { + NSLog(@"[MXDeviceList] Now tracking device list for %@", userId); + deviceTrackingStatus[userId] = @(MXDeviceTrackingStatusPendingDownload); + } + // we don't yet persist the tracking status, since there may be a lot + // of calls; instead we wait for the forthcoming + // refreshOutdatedDeviceLists. +} + - (void)invalidateUserDeviceList:(NSString *)userId { - [pendingUsersWithNewDevices addObject:userId]; + MXDeviceTrackingStatus trackingStatus = MXDeviceTrackingStatusFromNSNumber(deviceTrackingStatus[userId]); + + if (trackingStatus) + { + NSLog(@"[MXDeviceList] Marking device list outdated for %@", userId); + deviceTrackingStatus[userId] = @(MXDeviceTrackingStatusPendingDownload); + } + // we don't yet persist the tracking status, since there may be a lot + // of calls; instead we wait for the forthcoming + // refreshOutdatedDeviceLists. +} + +- (void)invalidateAllDeviceLists; +{ + for (NSString *userId in deviceTrackingStatus.allKeys) + { + [self invalidateUserDeviceList:userId]; + } } - (void)refreshOutdatedDeviceLists { - NSArray *users = pendingUsersWithNewDevices.allObjects; - if (users.count == 0) + NSMutableArray *users = [NSMutableArray array]; + for (NSString *userId in deviceTrackingStatus) { - // That means we're up-to-date with the lastKnownSyncToken - if (_lastKnownSyncToken) + MXDeviceTrackingStatus trackingStatus = MXDeviceTrackingStatusFromNSNumber(deviceTrackingStatus[userId]); + if (trackingStatus == MXDeviceTrackingStatusPendingDownload) { - [crypto.store storeDeviceSyncToken:_lastKnownSyncToken]; + [users addObject:userId]; } } - else + + if (users) { + // we didn't persist the tracking status during + // invalidateUserDeviceList, so do it now. + [self persistDeviceTrackingStatus]; + MXDeviceListOperation *operation = [[MXDeviceListOperation alloc] initWithUserIds:users success:^(NSArray *succeededUserIds, NSArray *failedUserIds) { NSLog(@"[MXDeviceList] refreshOutdatedDeviceLists: %@", succeededUserIds); @@ -214,15 +263,24 @@ - (void)refreshOutdatedDeviceLists } failure:^(NSError *error) { - NSLog(@"[MXDeviceList] refreshOutdatedDeviceLists: ERROR updating device keys for users %@", pendingUsersWithNewDevices); - [pendingUsersWithNewDevices addObjectsFromArray:users]; + NSLog(@"[MXDeviceList] refreshOutdatedDeviceLists: ERROR updating device keys for users %@", users); + for (NSString *userId in users) + { + deviceTrackingStatus[userId] = @(MXDeviceTrackingStatusPendingDownload); + } + [self persistDeviceTrackingStatus]; } ]; [self startOrQueueDeviceQuery:operation]; } } +- (void)persistDeviceTrackingStatus +{ + [crypto.store storeDeviceTrackingStatus:deviceTrackingStatus]; +} + /** Get the stored device keys for a list of user ids. @@ -285,10 +343,6 @@ - (void)startCurrentPoolQuery { NSString *token = _lastKnownSyncToken; - // We've kicked off requests to these users: remove their - // pending flag for now. - [pendingUsersWithNewDevices minusSet:currentQueryPool.userIds]; - // Add token [currentQueryPool downloadKeys:token complete:^(NSDictionary *failedUserIds) { diff --git a/MatrixSDK/Crypto/Data/Store/MXCryptoStore.h b/MatrixSDK/Crypto/Data/Store/MXCryptoStore.h index 07f1b8cc1c..f50893fcc8 100644 --- a/MatrixSDK/Crypto/Data/Store/MXCryptoStore.h +++ b/MatrixSDK/Crypto/Data/Store/MXCryptoStore.h @@ -154,6 +154,20 @@ */ - (NSDictionary*)devicesForUser:(NSString*)userId; +/** + The device tracking status. + + @return A map from user id to MXDeviceTrackingStatus. + */ +- (NSDictionary*)deviceTrackingStatus; + +/** + Store the device tracking status. + + @param statusMap A map from user id to MXDeviceTrackingStatus. + */ +- (void)storeDeviceTrackingStatus:(NSDictionary*)statusMap; + /** Store the crypto algorithm for a room. diff --git a/MatrixSDK/Crypto/Data/Store/MXFileCryptoStore/MXFileCryptoStore.m b/MatrixSDK/Crypto/Data/Store/MXFileCryptoStore/MXFileCryptoStore.m index b33bb99370..846557badc 100644 --- a/MatrixSDK/Crypto/Data/Store/MXFileCryptoStore/MXFileCryptoStore.m +++ b/MatrixSDK/Crypto/Data/Store/MXFileCryptoStore/MXFileCryptoStore.m @@ -315,6 +315,16 @@ - (void)storeDevicesForUser:(NSString *)userId devices:(NSDictionary*)deviceTrackingStatus +{ + return nil; +} + +- (void)storeDeviceTrackingStatus:(NSDictionary*)statusMap +{ + +} + - (void)storeAlgorithmForRoom:(NSString *)roomId algorithm:(NSString *)algorithm { roomsAlgorithms[roomId] = algorithm; diff --git a/MatrixSDK/Crypto/Data/Store/MXRealmCryptoStore/MXRealmCryptoStore.m b/MatrixSDK/Crypto/Data/Store/MXRealmCryptoStore/MXRealmCryptoStore.m index d91eb398ee..eb9a9f3cfa 100644 --- a/MatrixSDK/Crypto/Data/Store/MXRealmCryptoStore/MXRealmCryptoStore.m +++ b/MatrixSDK/Crypto/Data/Store/MXRealmCryptoStore/MXRealmCryptoStore.m @@ -126,6 +126,12 @@ @interface MXRealmOlmAccount : RLMObject */ @property (nonatomic) NSString *deviceSyncToken; +/** + NSData serialisation of users we are tracking device status for. + userId -> MXDeviceTrackingStatus* + */ +@property (nonatomic) NSData *deviceTrackingStatusData; + /** Settings for blacklisting unverified devices. */ @@ -429,6 +435,21 @@ - (void)storeDevicesForUser:(NSString*)userID devices:(NSDictionary*)deviceTrackingStatus +{ + MXRealmOlmAccount *account = self.accountInCurrentThread; + return [NSKeyedUnarchiver unarchiveObjectWithData:account.deviceTrackingStatusData]; +} + +- (void)storeDeviceTrackingStatus:(NSDictionary*)statusMap +{ + MXRealmOlmAccount *account = self.accountInCurrentThread; + [account.realm transactionWithBlock:^{ + + account.deviceTrackingStatusData = [NSKeyedArchiver archivedDataWithRootObject:statusMap]; + }]; +} + - (void)storeAlgorithmForRoom:(NSString*)roomId algorithm:(NSString*)algorithm { BOOL isNew = NO; diff --git a/MatrixSDK/Crypto/MXCrypto.m b/MatrixSDK/Crypto/MXCrypto.m index 385818d45b..30d0947296 100644 --- a/MatrixSDK/Crypto/MXCrypto.m +++ b/MatrixSDK/Crypto/MXCrypto.m @@ -75,7 +75,7 @@ @interface MXCrypto () // The operation used for crypto starting requests MXHTTPOperation *startOperation; - BOOL initialDeviceListInvalidationDone; + BOOL initialDeviceListInvalidationPending; } @end @@ -347,7 +347,7 @@ - (MXHTTPOperation *)encryptEventContent:(NSDictionary *)eventContent withType:( algorithm = room.state.encryptionAlgorithm; if (algorithm) { - [self setEncryptionInRoom:room.roomId withAlgorithm:algorithm]; + [self setEncryptionInRoom:room.roomId withAlgorithm:algorithm inhibitDeviceQuery:NO]; alg = roomEncryptors[room.roomId]; } } @@ -473,7 +473,7 @@ - (MXHTTPOperation*)ensureEncryptionInRoom:(NSString*)roomId algorithm = room.state.encryptionAlgorithm; if (algorithm) { - [self setEncryptionInRoom:room.roomId withAlgorithm:algorithm]; + [self setEncryptionInRoom:room.roomId withAlgorithm:algorithm inhibitDeviceQuery:NO]; alg = roomEncryptors[room.roomId]; } } @@ -564,9 +564,10 @@ - (void)handleDeviceListsChanged:(NSArray*)userIds oldSyncToken:(NSS { NSLog(@"[MXCrypto] handleDeviceListsChanged: Completed initialsync; invalidating device list from deviceSyncToken: %@", oldDeviceSyncToken); + initialDeviceListInvalidationPending = YES; + [self invalidateDeviceListsSince:oldDeviceSyncToken to:nextSyncToken success:^(NSArray *changed) { - initialDeviceListInvalidationDone = YES; _deviceList.lastKnownSyncToken = nextSyncToken; [_deviceList refreshOutdatedDeviceLists]; @@ -574,31 +575,32 @@ - (void)handleDeviceListsChanged:(NSArray*)userIds oldSyncToken:(NSS // If that failed, we fall back to invalidating everyone. NSLog(@"[MXCrypto] handleDeviceListsChanged: Error fetching changed device list. Error: %@", error); - [self invalidateDeviceListForAllActiveUsers]; - [_deviceList refreshOutdatedDeviceLists]; + [_deviceList invalidateAllDeviceLists]; }]; } else { // Otherwise, we have to invalidate all devices for all users we - // share a room with. + // are tracking. NSLog(@"[MXCrypto] handleDeviceListsChanged: Completed first initialsync; invalidating all device list caches"); - [self invalidateDeviceListForAllActiveUsers]; - initialDeviceListInvalidationDone = YES; + [_deviceList invalidateAllDeviceLists]; } } - if (initialDeviceListInvalidationDone) + if (!initialDeviceListInvalidationPending) { - // If we've got an up-to-date list of users with outdated device lists, - // tell the device list about the new sync token (but not otherwise, because - // otherwise we'll start thinking we're more in sync than we are.) - _deviceList.lastKnownSyncToken = nextSyncToken; - - // Catch up on any new devices we got told about during the sync. - [_deviceList refreshOutdatedDeviceLists]; + // we can now store our sync token so that we can get an update on + // restart rather than having to invalidate everyone. + // + // (we don't really need to do this on every sync - we could just + // do it periodically) + [_store storeDeviceSyncToken:nextSyncToken]; } + // catch up on any new devices we got told about during the sync. + _deviceList.lastKnownSyncToken = nextSyncToken; + [_deviceList refreshOutdatedDeviceLists]; + // We don't start uploading one-time keys until we've caught up with // to-device messages, to help us avoid throwing away one-time-keys that we // are about to receive messages for @@ -1084,7 +1086,7 @@ - (instancetype)initWithMatrixSession:(MXSession*)matrixSession cryptoQueue:(dis roomEncryptors = [NSMutableDictionary dictionary]; roomDecryptors = [NSMutableDictionary dictionary]; - initialDeviceListInvalidationDone = NO; + initialDeviceListInvalidationPending = NO; // Build our device keys: they will later be uploaded NSString *deviceId = _store.deviceId; @@ -1163,7 +1165,7 @@ - (MXDeviceInfo *)eventSenderDeviceOfEvent:(MXEvent *)event return device; } --(BOOL)setEncryptionInRoom:(NSString*)roomId withAlgorithm:(NSString*)algorithm +- (BOOL)setEncryptionInRoom:(NSString*)roomId withAlgorithm:(NSString*)algorithm inhibitDeviceQuery:(BOOL)inhibitDeviceQuery { // If we already have encryption in this room, we should ignore this event // (for now at least. Maybe we should alert the user somehow?) @@ -1190,23 +1192,18 @@ -(BOOL)setEncryptionInRoom:(NSString*)roomId withAlgorithm:(NSString*)algorithm roomEncryptors[roomId] = alg; - // if encryption was not previously enabled in this room, we will have been - // ignoring new device events for these users so far. We may well have - // up-to-date lists for some users, for instance if we were sharing other - // e2e rooms with them, so there is room for optimisation here, but for now - // we just invalidate everyone in the room. - if (!existingAlgorithm) - { - NSLog(@"[MXCrypto] setEncryptionInRoom: Enabling encryption in %@ for the first time; invalidating device lists for all users therein", roomId); + // make sure we are tracking the device lists for all users in this room. + NSLog(@"[MXCrypto] setEncryptionInRoom: Enabling encryption in %@; starting to track device lists for all users therein", roomId); - MXRoom *room = [mxSession roomWithRoomId:roomId]; - for (MXRoomMember *member in room.state.joinedMembers) - { - [_deviceList invalidateUserDeviceList:member.userId]; - } + MXRoom *room = [mxSession roomWithRoomId:roomId]; + for (MXRoomMember *member in room.state.joinedMembers) + { + [_deviceList startTrackingDeviceList:member.userId]; + } - // the actual refresh happens once we've finished processing the sync, - // in _onSyncCompleted. + if (!inhibitDeviceQuery) + { + [_deviceList refreshOutdatedDeviceLists]; } return YES; @@ -1483,18 +1480,11 @@ - (void)invalidateDeviceListsSince:(NSString*)oldSyncToken to:(NSString*)lastKno { [_matrixRestClient keyChangesFrom:oldSyncToken to:lastKnownSyncToken success:^(NSArray *changed) { - if (changed.count) + NSLog(@"[MXCrypto] invalidateDeviceListsSince: got key changes since %@: %@", oldSyncToken, changed); + + for (NSString *userId in changed) { - // Only invalidate users we share an e2e room with - we don't - // care about users in non-e2e rooms. - NSArray *filteredUserIds = self.e2eRoomMembers.allKeys; - for (NSString *changedUser in changed) - { - if ([filteredUserIds containsObject:changedUser]) - { - [_deviceList invalidateUserDeviceList:changedUser]; - } - } + [_deviceList invalidateUserDeviceList:userId]; } success(changed); @@ -1502,17 +1492,6 @@ - (void)invalidateDeviceListsSince:(NSString*)oldSyncToken to:(NSString*)lastKno } failure:failure]; } -/** - Invalidate any stored device list for any users we share an e2e room with - */ -- (void)invalidateDeviceListForAllActiveUsers -{ - for (NSString *userId in self.e2eRoomMembers.allKeys) - { - [_deviceList invalidateUserDeviceList:userId]; - } -} - /** Get a list of the e2e-enabled rooms we are members of. @@ -1581,7 +1560,7 @@ - (void)registerEventHandlers [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onToDeviceEvent:) name:kMXSessionOnToDeviceEventNotification object:mxSession]; // Observe membership changes - roomMembershipEventsListener = [mxSession listenToEventsOfTypes:@[kMXEventTypeStringRoomEncryption] onEvent:^(MXEvent *event, MXTimelineDirection direction, id customObject) { + roomMembershipEventsListener = [mxSession listenToEventsOfTypes:@[kMXEventTypeStringRoomEncryption, kMXEventTypeStringRoomMember] onEvent:^(MXEvent *event, MXTimelineDirection direction, id customObject) { if (direction == MXTimelineDirectionForwards) { @@ -1589,6 +1568,10 @@ - (void)registerEventHandlers { [self onCryptoEvent:event]; } + else if (event.eventType == MXEventTypeRoomMember) + { + [self onRoomMembership:event]; + } } }]; @@ -1795,10 +1778,42 @@ - (void)onCryptoEvent:(MXEvent*)event if (_cryptoQueue) { dispatch_async(_cryptoQueue, ^{ - [self setEncryptionInRoom:event.roomId withAlgorithm:event.content[@"algorithm"]]; + [self setEncryptionInRoom:event.roomId withAlgorithm:event.content[@"algorithm"] inhibitDeviceQuery:YES]; }); } -}; +} + +/** + Handle a change in the membership state of a member of a room. + + @param event the membership event causing the change + */ +- (void)onRoomMembership:(MXEvent*)event +{ + id alg = roomEncryptors[event.roomId]; + if (!alg) + { + // No encrypting in this room + return; + } + + NSString *userId = event.stateKey; + MXRoomMember *member = [[mxSession roomWithRoomId:event.roomId].state memberWithUserId:userId]; + + if (member && member.membership == MXMembershipJoin) + { + NSLog(@"[MXCrypto] onRoomMembership: Join event for %@ in %@", member.userId, event.roomId); + + if (_cryptoQueue) + { + dispatch_async(_cryptoQueue, ^{ + + // make sure we are tracking the deviceList for this user + [_deviceList startTrackingDeviceList:member.userId ]; + }); + } + } +} /** Upload my user's device keys. diff --git a/MatrixSDK/Crypto/MXCrypto_Private.h b/MatrixSDK/Crypto/MXCrypto_Private.h index 36b8a80a18..fb6b91d4d4 100644 --- a/MatrixSDK/Crypto/MXCrypto_Private.h +++ b/MatrixSDK/Crypto/MXCrypto_Private.h @@ -90,9 +90,10 @@ @param roomId the room id to enable encryption in. @param algorithm the encryption config for the room. + @param inhibitDeviceQuery YES to suppress device list query for users in the room (for now) @return YES if the operation succeeds. */ -- (BOOL)setEncryptionInRoom:(NSString*)roomId withAlgorithm:(NSString*)algorithm; +- (BOOL)setEncryptionInRoom:(NSString*)roomId withAlgorithm:(NSString*)algorithm inhibitDeviceQuery:(BOOL)inhibitDeviceQuery; /** Try to make sure we have established olm sessions for the given users.