diff --git a/lib/matrix_api_lite.dart b/lib/matrix_api_lite.dart index 8cd63c62..096b476d 100644 --- a/lib/matrix_api_lite.dart +++ b/lib/matrix_api_lite.dart @@ -61,7 +61,6 @@ export 'src/model/room_creation_types.dart'; export 'src/model/room_summary.dart'; export 'src/model/stripped_state_event.dart'; export 'src/model/sync_update.dart'; -export 'src/model/upload_key_signatures_response.dart'; export 'src/utils/logs.dart'; export 'src/utils/map_copy_extension.dart'; export 'src/utils/try_get_map_extension.dart'; diff --git a/lib/src/matrix_api.dart b/lib/src/matrix_api.dart index f64b633c..903d2bee 100644 --- a/lib/src/matrix_api.dart +++ b/lib/src/matrix_api.dart @@ -32,7 +32,6 @@ import 'generated/api.dart'; import 'model/matrix_connection_exception.dart'; import 'model/matrix_exception.dart'; import 'model/matrix_keys.dart'; -import 'model/upload_key_signatures_response.dart'; enum RequestType { GET, POST, PUT, DELETE } @@ -171,37 +170,6 @@ class MatrixApi extends Api { return Map.from(response['one_time_key_counts']); } - /// Uploads new signatures of keys - /// https://github.com/matrix-org/matrix-doc/pull/2536 - Future uploadKeySignatures( - List keys) async { - final payload = {}; - for (final key in keys) { - if (key.identifier == null || - key.signatures == null || - key.signatures!.isEmpty) { - continue; - } - if (!payload.containsKey(key.userId)) { - payload[key.userId] = {}; - } - if (payload[key.userId].containsKey(key.identifier)) { - // we need to merge signature objects - payload[key.userId][key.identifier]['signatures'] - .addAll(key.signatures); - } else { - // we can just add signatures - payload[key.userId][key.identifier] = key.toJson(); - } - } - final response = await request( - RequestType.POST, - '/client/r0/keys/signatures/upload', - data: payload, - ); - return UploadKeySignaturesResponse.fromJson(response); - } - /// This endpoint allows the creation, modification and deletion of pushers /// for this user ID. The behaviour of this endpoint varies depending on the /// values in the JSON body. diff --git a/lib/src/model/upload_key_signatures_response.dart b/lib/src/model/upload_key_signatures_response.dart deleted file mode 100644 index 38bf3774..00000000 --- a/lib/src/model/upload_key_signatures_response.dart +++ /dev/null @@ -1,59 +0,0 @@ -/* MIT License -* -* Copyright (C) 2019, 2020, 2021 Famedly GmbH -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all -* copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -import 'matrix_exception.dart'; - -class UploadKeySignaturesResponse { - Map>? failures; - - UploadKeySignaturesResponse.fromJson(Map json) - : failures = json['failures'] != null - ? (json['failures'] as Map).map( - (k, v) => MapEntry( - k, - (v as Map).map((k, v) => MapEntry( - k, - MatrixException.fromJson(v), - )), - ), - ) - : null; - - Map toJson() { - final data = {}; - if (failures != null) { - data['failures'] = failures!.map( - (k, v) => MapEntry( - k, - v.map( - (k, v) => MapEntry( - k, - v.raw, - ), - ), - ), - ); - } - return data; - } -} diff --git a/test/matrix_api_test.dart b/test/matrix_api_test.dart index d5fecb78..f615e5c5 100644 --- a/test/matrix_api_test.dart +++ b/test/matrix_api_test.dart @@ -1187,53 +1187,6 @@ void main() { selfSigningKey: selfSigningKey, userSigningKey: userSigningKey); }); - test('uploadKeySignatures', () async { - matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); - matrixApi.accessToken = '1234'; - - final key1 = MatrixDeviceKeys.fromJson({ - 'user_id': '@alice:example.com', - 'device_id': 'JLAFKJWSCS', - 'algorithms': [ - AlgorithmTypes.olmV1Curve25519AesSha2, - AlgorithmTypes.megolmV1AesSha2 - ], - 'keys': { - 'curve25519:JLAFKJWSCS': - '3C5BFWi2Y8MaVvjM8M22DBmh24PmgR0nPvJOIArzgyI', - 'ed25519:JLAFKJWSCS': 'lEuiRJBit0IG6nUf5pUzWTUEsRVVe/HJkoKuEww9ULI' - }, - 'signatures': { - '@alice:example.com': { - 'ed25519:JLAFKJWSCS': - 'dSO80A01XiigH3uBiDVx/EjzaoycHcjq9lfQX0uWsqxl2giMIiSPR8a4d291W1ihKJL/a+myXS367WT6NAIcBA' - } - }, - 'unsigned': {'device_display_name': 'Alices mobile phone'}, - }); - final key2 = MatrixDeviceKeys.fromJson({ - 'user_id': '@alice:example.com', - 'device_id': 'JLAFKJWSCS', - 'algorithms': [ - AlgorithmTypes.olmV1Curve25519AesSha2, - AlgorithmTypes.megolmV1AesSha2 - ], - 'keys': { - 'curve25519:JLAFKJWSCS': - '3C5BFWi2Y8MaVvjM8M22DBmh24PmgR0nPvJOIArzgyI', - 'ed25519:JLAFKJWSCS': 'lEuiRJBit0IG6nUf5pUzWTUEsRVVe/HJkoKuEww9ULI' - }, - 'signatures': { - '@alice:example.com': {'ed25519:OTHERDEVICE': 'OTHERSIG'} - }, - 'unsigned': {'device_display_name': 'Alices mobile phone'}, - }); - final ret = await matrixApi.uploadKeySignatures([key1, key2]); - expect( - FakeMatrixApi.api['POST']!['/client/r0/keys/signatures/upload']({}), - ret.toJson(), - ); - }); test('requestPushers', () async { matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.accessToken = '1234';