File tree Expand file tree Collapse file tree 5 files changed +39
-0
lines changed
MatrixSDK/Crypto/Verification Expand file tree Collapse file tree 5 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,9 @@ NS_ASSUME_NONNULL_BEGIN
7171// The QR code is invalid
7272+ (instancetype )qrCodeInvalid ;
7373
74+ // Verification request accepted by another device
75+ + (instancetype )accepted ;
76+
7477@end
7578
7679NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change @@ -87,4 +87,9 @@ + (instancetype)qrCodeInvalid
8787 return [[MXTransactionCancelCode alloc ] initWithValue: @" m.qr_code.invalid" humanReadable: @" Invalid QR code" ];
8888}
8989
90+ + (instancetype )accepted
91+ {
92+ return [[MXTransactionCancelCode alloc ] initWithValue: @" m.accepted" humanReadable: @" Verification request accepted by another device" ];
93+ }
94+
9095@end
Original file line number Diff line number Diff line change @@ -203,6 +203,13 @@ FOUNDATION_EXPORT NSString *const MXKeyVerificationManagerNotificationTransactio
203203 */
204204- (void )removeQRCodeTransactionWithTransactionId : (NSString *)transactionId ;
205205
206+
207+ - (void )notifyOthersOfAcceptanceWithTransactionId : (NSString *)transactionId
208+ acceptedUserId : (NSString *)acceptedUserId
209+ acceptedDeviceId : (NSString *)acceptedDeviceId
210+ success : (void (^)(void ))success
211+ failure : (void (^)(NSError *error))failure ;
212+
206213@end
207214
208215NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change @@ -687,6 +687,25 @@ - (MXHTTPOperation*)sendToOtherInRequest:(MXKeyVerificationRequest*)request
687687 return operation;
688688}
689689
690+ - (void )notifyOthersOfAcceptanceWithTransactionId : (NSString *)transactionId
691+ acceptedUserId : (NSString *)acceptedUserId
692+ acceptedDeviceId : (NSString *)acceptedDeviceId
693+ success : (void (^)(void ))success
694+ failure : (void (^)(NSError *error))failure
695+ {
696+ [self otherDeviceIdsOfUser: acceptedUserId success: ^(NSArray <NSString *> *deviceIds) {
697+ NSMutableArray *nonChosenDevices = [deviceIds mutableCopy ];
698+ [nonChosenDevices removeObject: acceptedDeviceId];
699+
700+ MXKeyVerificationCancel *cancel = [MXKeyVerificationCancel new ];
701+ MXTransactionCancelCode *cancelCode = MXTransactionCancelCode.accepted ;
702+ cancel.transactionId = transactionId;
703+ cancel.code = cancelCode.value ;
704+ cancel.reason = cancelCode.humanReadable ;
705+ [self sendToDevices: acceptedUserId deviceIds: nonChosenDevices eventType: kMXEventTypeStringKeyVerificationCancel content: cancel.JSONDictionary success: success failure: failure];
706+ } failure: failure];
707+ }
708+
690709- (void )cancelVerificationRequest : (MXKeyVerificationRequest*)request
691710 success : (void (^)(void ))success
692711 failure : (void (^)(NSError *error))failure
Original file line number Diff line number Diff line change @@ -197,6 +197,11 @@ - (void)handleReady:(MXKeyVerificationReady*)readyContent
197197 {
198198 [self updateState: MXKeyVerificationRequestStateReady notifiy: YES ];
199199 }
200+ [self .manager notifyOthersOfAcceptanceWithTransactionId: self .requestId acceptedUserId: self .otherUser acceptedDeviceId: self .otherDevice success: ^{
201+ MXLogDebug (@" [MXKeyVerificationRequest] handleReady notified others of acceptance" );
202+ } failure: ^(NSError * _Nonnull error) {
203+ MXLogError (@" [MXKeyVerificationRequest] handleReady failed notify others of acceptance" );
204+ }];
200205}
201206
202207- (void )handleCancel : (MXKeyVerificationCancel *)cancelContent
You can’t perform that action at this time.
0 commit comments