refactor: mostly use dart_openapi_codegen

This commit is contained in:
Lukas Lihotzki 2021-06-24 17:36:35 +02:00
parent 3a6d224348
commit e3a1b6aa77
87 changed files with 6865 additions and 3484 deletions

View File

@ -18,4 +18,9 @@ void main() async {
print(capabilities.toJson());
}
```
```
## Generated code
The files in `lib/src/generated` are generated by [dart_openapi_codegen](https://gitlab.com/famedly/company/frontend/dart_openapi_codegen)
from [matrix-doc](https://github.com/matrix-org/matrix-doc/). See the README.md in dart_openapi_codegen for more information.

View File

@ -12,3 +12,4 @@ analyzer:
todo: ignore
exclude:
- example/matrix_api_lite_example.dart
- lib/src/generated/**.dart

View File

@ -1,3 +1,4 @@
// @dart=2.9
import 'package:matrix_api_lite/src/matrix_api.dart';
void main() async {

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
@ -753,12 +754,7 @@ class FakeMatrixApi extends MockClient {
'error': 'Blabla',
},
'/media/r0/preview_url?url=https%3A%2F%2Fmatrix.org&ts=10': (var req) => {
'og:title': 'Matrix Blog Post',
'og:description': 'This is a really cool blog post from matrix.org',
'og:image': 'mxc://example.com/ascERGshawAWawugaAcauga',
'og:image:type': 'image/png',
'og:image:height': 48,
'og:image:width': 48,
'matrix:image:size': 102400
},
'/media/r0/config': (var req) => {'m.upload.size': 50000000},
@ -910,7 +906,7 @@ class FakeMatrixApi extends MockClient {
'com.example.custom.ratelimit': {'max_requests_per_hour': 600}
}
},
'/client/r0/rooms/1234/context/1234?filter=%7B%7D&limit=10': (var req) =>
'/client/r0/rooms/1234/context/1234?limit=10&filter=%7B%7D': (var req) =>
{
'end': 't29-57_2_0_2',
'events_after': [
@ -1271,7 +1267,7 @@ class FakeMatrixApi extends MockClient {
'origin_server_ts': 1432735824653,
'unsigned': {'age': 1234}
},
'/client/r0/rooms/!localpart%3Aserver.abc/messages?from=1234&dir=b&to=1234&limit=10&filter=%7B%22lazy_load_members%22%3Atrue%7D':
'/client/r0/rooms/!localpart%3Aserver.abc/messages?from=1234&to=1234&dir=b&limit=10&filter=%7B%22lazy_load_members%22%3Atrue%7D':
(var req) => messagesResponse,
'/client/r0/rooms/!localpart%3Aserver.abc/messages?from=&dir=b&limit=10&filter=%7B%22lazy_load_members%22%3Atrue%7D':
(var req) => messagesResponse,
@ -1989,7 +1985,7 @@ class FakeMatrixApi extends MockClient {
'access_token': 'SomeT0kenHere',
'token_type': 'Bearer',
'matrix_server_name': 'example.com',
'expires_in': 3600.0
'expires_in': 3600
},
'/client/r0/user/@test:fakeServer.notExisting/openid/request_token':
(var req) => {

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
@ -24,6 +25,8 @@
library matrix_api_lite;
export 'src/matrix_api.dart';
export 'src/values.dart';
export 'src/generated/model.dart';
export 'src/utils/logs.dart';
export 'src/utils/map_copy_extension.dart';
export 'src/utils/try_get_map_extension.dart';
@ -31,50 +34,25 @@ export 'src/model/algorithm_types.dart';
export 'src/model/basic_event.dart';
export 'src/model/basic_event_with_sender.dart';
export 'src/model/basic_room_event.dart';
export 'src/model/device.dart';
export 'src/model/event_context.dart';
export 'src/model/event_types.dart';
export 'src/model/events_sync_update.dart';
export 'src/model/filter.dart';
export 'src/model/keys_query_response.dart';
export 'src/model/login_response.dart';
export 'src/model/login_types.dart';
export 'src/model/matrix_connection_exception.dart';
export 'src/model/matrix_event.dart';
export 'src/model/matrix_exception.dart';
export 'src/model/matrix_keys.dart';
export 'src/model/message_types.dart';
export 'src/model/notifications_query_response.dart';
export 'src/model/one_time_keys_claim_response.dart';
export 'src/model/open_graph_data.dart';
export 'src/model/open_id_credentials.dart';
export 'src/model/presence.dart';
export 'src/model/presence_content.dart';
export 'src/model/profile.dart';
export 'src/model/public_rooms_response.dart';
export 'src/model/push_rule_set.dart';
export 'src/model/pusher.dart';
export 'src/model/request_token_response.dart';
export 'src/model/room_alias_information.dart';
export 'src/model/room_creation_types.dart';
export 'src/model/room_keys_info.dart';
export 'src/model/room_keys_keys.dart';
export 'src/model/room_summary.dart';
export 'src/model/server_capabilities.dart';
export 'src/model/stripped_state_event.dart';
export 'src/model/supported_protocol.dart';
export 'src/model/supported_versions.dart';
export 'src/model/sync_update.dart';
export 'src/model/tag.dart';
export 'src/model/third_party_identifier.dart';
export 'src/model/third_party_location.dart';
export 'src/model/third_party_user.dart';
export 'src/model/timeline_history_response.dart';
export 'src/model/turn_server_credentials.dart';
export 'src/model/upload_key_signatures_response.dart';
export 'src/model/user_search_result.dart';
export 'src/model/well_known_information.dart';
export 'src/model/who_is_info.dart';
export 'src/model/auth/authentication_data.dart';
export 'src/model/auth/authentication_identifier.dart';
export 'src/model/auth/authentication_password.dart';

3553
lib/src/generated/api.dart Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
import 'dart:typed_data';
class FileResponse {
FileResponse({this.contentType, required this.data});
String? contentType;
Uint8List data;
}

View File

@ -0,0 +1,6 @@
import 'fixed_model.dart';
void ignore(Object? input) {}
FileResponse ignoreFile(dynamic input) {
throw UnimplementedError();
}

3113
lib/src/generated/model.dart Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,51 +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.
*/
class Device {
String deviceId;
String displayName;
String lastSeenIp;
DateTime lastSeenTs;
Device.fromJson(Map<String, dynamic> json)
: deviceId = json['device_id'],
displayName = json['display_name'],
lastSeenIp = json['last_seen_ip'],
lastSeenTs =
DateTime.fromMillisecondsSinceEpoch(json['last_seen_ts'] ?? 0);
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['device_id'] = deviceId;
if (displayName != null) {
data['display_name'] = displayName;
}
if (lastSeenIp != null) {
data['last_seen_ip'] = lastSeenIp;
}
if (lastSeenTs != null) {
data['last_seen_ts'] = lastSeenTs.millisecondsSinceEpoch;
}
return data;
}
}

View File

@ -1,75 +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_event.dart';
class EventContext {
String end;
List<MatrixEvent> eventsAfter;
MatrixEvent event;
List<MatrixEvent> eventsBefore;
String start;
List<MatrixEvent> state;
EventContext.fromJson(Map<String, dynamic> json)
: end = json['end'],
eventsAfter = (json['events_after'] != null)
? (json['events_after'] as List)
.map((v) => MatrixEvent.fromJson(v))
.toList()
: null,
event =
json['event'] != null ? MatrixEvent.fromJson(json['event']) : null,
eventsBefore = (json['events_before'] != null)
? (json['events_before'] as List)
.map((v) => MatrixEvent.fromJson(v))
.toList()
: null,
start = json['start'],
state = (json['state'] != null)
? (json['state'] as List)
.map((v) => MatrixEvent.fromJson(v))
.toList()
: null;
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (end != null) {
data['end'] = end;
}
if (eventsAfter != null) {
data['events_after'] = eventsAfter.map((v) => v.toJson()).toList();
}
if (event != null) {
data['event'] = event.toJson();
}
if (eventsBefore != null) {
data['events_before'] = eventsBefore.map((v) => v.toJson()).toList();
}
data['start'] = start;
if (state != null) {
data['state'] = state.map((v) => v.toJson()).toList();
}
return data;
}
}

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,219 +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.
*/
enum EventFormat { client, federation }
class Filter {
RoomFilter room;
EventFilter presence;
EventFilter accountData;
EventFormat eventFormat;
List<String> eventFields;
Filter({
this.room,
this.presence,
this.accountData,
this.eventFormat,
this.eventFields,
});
Filter.fromJson(Map<String, dynamic> json)
: room = json['room'] != null ? RoomFilter.fromJson(json['room']) : null,
presence = json['presence'] != null
? EventFilter.fromJson(json['presence'])
: null,
accountData = json['account_data'] != null
? EventFilter.fromJson(json['account_data'])
: null,
eventFormat = json['event_format'] != null
? EventFormat.values.firstWhere(
(e) => e.toString().split('.').last == json['event_format'])
: null,
eventFields = json['event_fields'] != null
? json['event_fields'].cast<String>()
: null;
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (room != null) {
data['room'] = room.toJson();
}
if (presence != null) {
data['presence'] = presence.toJson();
}
if (eventFormat != null) {
data['event_format'] = eventFormat.toString().split('.').last;
}
if (eventFields != null) {
data['event_fields'] = eventFields;
}
if (accountData != null) {
data['account_data'] = accountData.toJson();
}
return data;
}
}
class RoomFilter {
List<String> notRooms;
List<String> rooms;
StateFilter ephemeral;
bool includeLeave;
StateFilter state;
StateFilter timeline;
StateFilter accountData;
RoomFilter({
this.notRooms,
this.rooms,
this.ephemeral,
this.includeLeave,
this.state,
this.timeline,
this.accountData,
});
RoomFilter.fromJson(Map<String, dynamic> json) {
notRooms = json['not_rooms']?.cast<String>();
rooms = json['rooms']?.cast<String>();
state = json['state'] != null ? StateFilter.fromJson(json['state']) : null;
includeLeave = json['include_leave'];
timeline = json['timeline'] != null
? StateFilter.fromJson(json['timeline'])
: null;
ephemeral = json['ephemeral'] != null
? StateFilter.fromJson(json['ephemeral'])
: null;
accountData = json['account_data'] != null
? StateFilter.fromJson(json['account_data'])
: null;
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (notRooms != null) {
data['not_rooms'] = notRooms;
}
if (rooms != null) {
data['rooms'] = rooms;
}
if (ephemeral != null) {
data['ephemeral'] = ephemeral.toJson();
}
if (includeLeave != null) {
data['include_leave'] = includeLeave;
}
if (state != null) {
data['state'] = state.toJson();
}
if (timeline != null) {
data['timeline'] = timeline.toJson();
}
if (accountData != null) {
data['account_data'] = accountData.toJson();
}
return data;
}
}
class EventFilter {
int limit;
List<String> senders;
List<String> types;
List<String> notRooms;
List<String> notSenders;
EventFilter(
{this.limit, this.senders, this.types, this.notRooms, this.notSenders});
EventFilter.fromJson(Map<String, dynamic> json) {
limit = json['limit'];
types = json['senders']?.cast<String>();
types = json['types']?.cast<String>();
notRooms = json['not_rooms']?.cast<String>();
notSenders = json['not_senders']?.cast<String>();
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (limit != null) data['limit'] = limit;
if (types != null) data['types'] = types;
if (notRooms != null) data['not_rooms'] = notRooms;
if (notSenders != null) data['not_senders'] = notSenders;
return data;
}
}
class StateFilter extends EventFilter {
List<String> notTypes;
bool lazyLoadMembers;
bool includeRedundantMembers;
bool containsUrl;
StateFilter({
this.notTypes,
this.lazyLoadMembers,
this.includeRedundantMembers,
this.containsUrl,
int limit,
List<String> senders,
List<String> types,
List<String> notRooms,
List<String> notSenders,
}) : super(
limit: limit,
senders: senders,
types: types,
notRooms: notRooms,
notSenders: notSenders,
);
StateFilter.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
notTypes = json['not_types']?.cast<String>();
lazyLoadMembers = json['lazy_load_members'];
includeRedundantMembers = json['include_redundant_members'];
containsUrl = json['contains_url'];
}
@override
Map<String, dynamic> toJson() {
final data = super.toJson();
if (limit != null) {
data['limit'] = limit;
}
if (notTypes != null) {
data['not_types'] = notTypes;
}
if (lazyLoadMembers != null) {
data['lazy_load_members'] = lazyLoadMembers;
}
if (includeRedundantMembers != null) {
data['include_redundant_members'] = includeRedundantMembers;
}
if (containsUrl != null) {
data['contains_url'] = containsUrl;
}
return data;
}
}

View File

@ -1,118 +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_keys.dart';
import '../utils/map_copy_extension.dart';
class KeysQueryResponse {
Map<String, dynamic> failures;
Map<String, Map<String, MatrixDeviceKeys>> deviceKeys;
Map<String, MatrixCrossSigningKey> masterKeys;
Map<String, MatrixCrossSigningKey> selfSigningKeys;
Map<String, MatrixCrossSigningKey> userSigningKeys;
KeysQueryResponse.fromJson(Map<String, dynamic> json)
: failures = (json['failures'] as Map<String, dynamic>)?.copy(),
deviceKeys = json['device_keys'] != null
? (json['device_keys'] as Map).map(
(k, v) => MapEntry(
k,
(v as Map).map(
(k, v) => MapEntry(
k,
MatrixDeviceKeys.fromJson(v),
),
),
),
)
: null,
masterKeys = json['master_keys'] != null
? (json['master_keys'] as Map).map(
(k, v) => MapEntry(
k,
MatrixCrossSigningKey.fromJson(v),
),
)
: null,
selfSigningKeys = json['self_signing_keys'] != null
? (json['self_signing_keys'] as Map).map(
(k, v) => MapEntry(
k,
MatrixCrossSigningKey.fromJson(v),
),
)
: null,
userSigningKeys = json['user_signing_keys'] != null
? (json['user_signing_keys'] as Map).map(
(k, v) => MapEntry(
k,
MatrixCrossSigningKey.fromJson(v),
),
)
: null;
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (failures != null) {
data['failures'] = failures;
}
if (deviceKeys != null) {
data['device_keys'] = deviceKeys.map(
(k, v) => MapEntry(
k,
v.map(
(k, v) => MapEntry(
k,
v.toJson(),
),
),
),
);
}
if (masterKeys != null) {
data['master_keys'] = masterKeys.map(
(k, v) => MapEntry(
k,
v.toJson(),
),
);
}
if (selfSigningKeys != null) {
data['self_signing_keys'] = selfSigningKeys.map(
(k, v) => MapEntry(
k,
v.toJson(),
),
);
}
if (userSigningKeys != null) {
data['user_signing_keys'] = userSigningKeys.map(
(k, v) => MapEntry(
k,
v.toJson(),
),
);
}
return data;
}
}

View File

@ -1,50 +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 'well_known_information.dart';
class LoginResponse {
String userId;
String accessToken;
String deviceId;
WellKnownInformation wellKnownInformation;
LoginResponse.fromJson(Map<String, dynamic> json)
: userId = json['user_id'],
accessToken = json['access_token'],
deviceId = json['device_id'],
wellKnownInformation = (json['well_known'] is Map)
? WellKnownInformation.fromJson(json['well_known'])
: null;
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (userId != null) data['user_id'] = userId;
if (accessToken != null) data['access_token'] = accessToken;
if (deviceId != null) data['device_id'] = deviceId;
if (wellKnownInformation != null) {
data['well_known'] = wellKnownInformation.toJson();
}
return data;
}
}

View File

@ -1,54 +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.
*/
class LoginTypes {
List<Flows> flows;
LoginTypes.fromJson(Map<String, dynamic> json) {
if (json['flows'] != null) {
flows = (json['flows'] as List).map((v) => Flows.fromJson(v)).toList();
}
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (flows != null) {
data['flows'] = flows.map((v) => v.toJson()).toList();
}
return data;
}
}
class Flows {
String type;
Flows.fromJson(Map<String, dynamic> json) {
type = json['type'];
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['type'] = type;
return data;
}
}

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,75 +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_event.dart';
class NotificationsQueryResponse {
String nextToken;
List<Notification> notifications;
NotificationsQueryResponse.fromJson(Map<String, dynamic> json)
: nextToken = json['next_token'],
notifications = (json['notifications'] as List)
.map((v) => Notification.fromJson(v))
.toList();
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (nextToken != null) {
data['next_token'] = nextToken;
}
data['notifications'] = notifications.map((v) => v.toJson()).toList();
return data;
}
}
class Notification {
List<String> actions;
String profileTag;
bool read;
String roomId;
int ts;
MatrixEvent event;
Notification.fromJson(Map<String, dynamic> json) {
actions = json['actions'].cast<String>();
profileTag = json['profile_tag'];
read = json['read'];
roomId = json['room_id'];
ts = json['ts'];
event = MatrixEvent.fromJson(json['event']);
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['actions'] = actions;
if (profileTag != null) {
data['profile_tag'] = profileTag;
}
data['read'] = read;
data['room_id'] = roomId;
data['ts'] = ts;
data['event'] = event.toJson();
return data;
}
}

View File

@ -1,46 +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 '../utils/map_copy_extension.dart';
class OneTimeKeysClaimResponse {
Map<String, dynamic> failures;
Map<String, Map<String, dynamic>> oneTimeKeys;
OneTimeKeysClaimResponse.fromJson(Map<String, dynamic> json)
: failures = (json['failures'] as Map<String, dynamic>)?.copy() ?? {},
// We still need a Map<...>.from(...) to ensure all second-level entries are also maps
oneTimeKeys = Map<String, Map<String, dynamic>>.from(
(json['one_time_keys'] as Map<String, dynamic>).copy());
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (failures != null) {
data['failures'] = failures;
}
if (oneTimeKeys != null) {
data['one_time_keys'] = oneTimeKeys;
}
return data;
}
}

View File

@ -1,67 +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.
*/
class OpenGraphData {
String ogTitle;
String ogDescription;
String ogImage;
String ogImageType;
int ogImageHeight;
int ogImageWidth;
int matrixImageSize;
OpenGraphData.fromJson(Map<String, dynamic> json)
: ogTitle = json['og:title'],
ogDescription = json['og:description'],
ogImage = json['og:image'],
ogImageType = json['og:image:type'],
ogImageHeight = json['og:image:height'],
ogImageWidth = json['og:image:width'],
matrixImageSize = json['matrix:image:size'];
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (ogTitle != null) {
data['og:title'] = ogTitle;
}
if (ogDescription != null) {
data['og:description'] = ogDescription;
}
if (ogImage != null) {
data['og:image'] = ogImage;
}
if (ogImageType != null) {
data['og:image:type'] = ogImageType;
}
if (ogImageHeight != null) {
data['og:image:height'] = ogImageHeight;
}
if (ogImageWidth != null) {
data['og:image:width'] = ogImageWidth;
}
if (matrixImageSize != null) {
data['matrix:image:size'] = matrixImageSize;
}
return data;
}
}

View File

@ -1,44 +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.
*/
class OpenIdCredentials {
String accessToken;
String tokenType;
String matrixServerName;
double expiresIn;
OpenIdCredentials.fromJson(Map<String, dynamic> json)
: accessToken = json['access_token'],
tokenType = json['token_type'],
matrixServerName = json['matrix_server_name'],
expiresIn = json['expires_in'];
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['access_token'] = accessToken;
data['token_type'] = tokenType;
data['matrix_server_name'] = matrixServerName;
data['expires_in'] = expiresIn;
return data;
}
}

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
@ -21,7 +22,7 @@
* SOFTWARE.
*/
enum PresenceType { online, offline, unavailable }
import '../generated/model.dart';
class PresenceContent {
PresenceType presence;

View File

@ -1,49 +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.
*/
class Profile {
/// The user's avatar URL if they have set one, otherwise null.
Uri avatarUrl;
/// The user's display name if they have set one, otherwise null.
String displayname;
/// The matrix ID of this user. May be omitted.
String userId;
Map<String, dynamic> additionalContent;
Profile(this.displayname, this.avatarUrl,
{this.additionalContent = const {}});
Profile.fromJson(Map<String, dynamic> json)
: avatarUrl =
json['avatar_url'] != null ? Uri.parse(json['avatar_url']) : null,
displayname = json['display_name'] ?? json['displayname'],
userId = json['user_id'],
additionalContent = json;
Map<String, dynamic> toJson() {
return additionalContent;
}
}

View File

@ -1,98 +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.
*/
class PublicRoomsResponse {
List<PublicRoom> chunk;
String nextBatch;
String prevBatch;
int totalRoomCountEstimate;
PublicRoomsResponse.fromJson(Map<String, dynamic> json)
: chunk =
(json['chunk'] as List).map((v) => PublicRoom.fromJson(v)).toList(),
nextBatch = json['next_batch'],
prevBatch = json['prev_batch'],
totalRoomCountEstimate = json['total_room_count_estimate'];
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['chunk'] = chunk.map((v) => v.toJson()).toList();
if (nextBatch != null) {
data['next_batch'] = nextBatch;
}
if (prevBatch != null) {
data['prev_batch'] = prevBatch;
}
if (totalRoomCountEstimate != null) {
data['total_room_count_estimate'] = totalRoomCountEstimate;
}
return data;
}
}
class PublicRoom {
List<String> aliases;
String avatarUrl;
bool guestCanJoin;
String name;
int numJoinedMembers;
String roomId;
String topic;
bool worldReadable;
String canonicalAlias;
PublicRoom.fromJson(Map<String, dynamic> json)
: aliases = json['aliases']?.cast<String>(),
avatarUrl = json['avatar_url'],
guestCanJoin = json['guest_can_join'],
canonicalAlias = json['canonical_alias'],
name = json['name'],
numJoinedMembers = json['num_joined_members'],
roomId = json['room_id'],
topic = json['topic'],
worldReadable = json['world_readable'];
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (aliases != null) {
data['aliases'] = aliases;
}
if (canonicalAlias != null) {
data['canonical_alias'] = canonicalAlias;
}
if (avatarUrl != null) {
data['avatar_url'] = avatarUrl;
}
data['guest_can_join'] = guestCanJoin;
if (name != null) {
data['name'] = name;
}
data['num_joined_members'] = numJoinedMembers;
data['room_id'] = roomId;
if (topic != null) {
data['topic'] = topic;
}
data['world_readable'] = worldReadable;
return data;
}
}

View File

@ -1,148 +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.
*/
enum PushRuleKind { content, override, room, sender, underride }
enum PushRuleAction { notify, dont_notify, coalesce, set_tweak }
class PushRuleSet {
List<PushRule> content;
List<PushRule> override;
List<PushRule> room;
List<PushRule> sender;
List<PushRule> underride;
PushRuleSet.fromJson(Map<String, dynamic> json) {
if (json['content'] != null) {
content =
(json['content'] as List).map((i) => PushRule.fromJson(i)).toList();
}
if (json['override'] != null) {
override =
(json['override'] as List).map((i) => PushRule.fromJson(i)).toList();
}
if (json['room'] != null) {
room = (json['room'] as List).map((i) => PushRule.fromJson(i)).toList();
}
if (json['sender'] != null) {
sender =
(json['sender'] as List).map((i) => PushRule.fromJson(i)).toList();
}
if (json['underride'] != null) {
underride =
(json['underride'] as List).map((i) => PushRule.fromJson(i)).toList();
}
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (content != null) {
data['content'] = content.map((v) => v.toJson()).toList();
}
if (override != null) {
data['override'] = override.map((v) => v.toJson()).toList();
}
if (room != null) {
data['room'] = room.map((v) => v.toJson()).toList();
}
if (sender != null) {
data['sender'] = sender.map((v) => v.toJson()).toList();
}
if (underride != null) {
data['underride'] = underride.map((v) => v.toJson()).toList();
}
return data;
}
}
class PushRule {
List<dynamic> actions;
List<PushConditions> conditions;
bool isDefault;
bool enabled;
String pattern;
String ruleId;
PushRule.fromJson(Map<String, dynamic> json) {
actions = json['actions'];
isDefault = json['default'];
enabled = json['enabled'];
pattern = json['pattern'];
ruleId = json['rule_id'];
conditions = json['conditions'] != null
? (json['conditions'] as List)
.map((i) => PushConditions.fromJson(i))
.toList()
: null;
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['actions'] = actions;
data['default'] = isDefault;
data['enabled'] = enabled;
if (pattern != null) {
data['pattern'] = pattern;
}
if (conditions != null) {
data['conditions'] = conditions.map((i) => i.toJson()).toList();
}
data['rule_id'] = ruleId;
return data;
}
}
class PushConditions {
String key;
String kind;
String pattern;
String isOperator;
PushConditions(
this.kind, {
this.key,
this.pattern,
this.isOperator,
});
PushConditions.fromJson(Map<String, dynamic> json) {
key = json['key'];
kind = json['kind'];
pattern = json['pattern'];
isOperator = json['is'];
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (key != null) {
data['key'] = key;
}
data['kind'] = kind;
if (pattern != null) {
data['pattern'] = pattern;
}
if (isOperator != null) {
data['is'] = isOperator;
}
return data;
}
}

View File

@ -1,94 +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.
*/
class Pusher {
String pushkey;
String kind;
String appId;
String appDisplayName;
String deviceDisplayName;
String profileTag;
String lang;
PusherData data;
Pusher(
this.pushkey,
this.appId,
this.appDisplayName,
this.deviceDisplayName,
this.lang,
this.data, {
this.profileTag,
this.kind,
});
Pusher.fromJson(Map<String, dynamic> json)
: pushkey = json['pushkey'],
kind = json['kind'],
appId = json['app_id'],
appDisplayName = json['app_display_name'],
deviceDisplayName = json['device_display_name'],
profileTag = json['profile_tag'],
lang = json['lang'],
data = PusherData.fromJson(json['data']);
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['pushkey'] = pushkey;
data['kind'] = kind;
data['app_id'] = appId;
data['app_display_name'] = appDisplayName;
data['device_display_name'] = deviceDisplayName;
if (profileTag != null) {
data['profile_tag'] = profileTag;
}
data['lang'] = lang;
data['data'] = this.data.toJson();
return data;
}
}
class PusherData {
Uri url;
String format;
PusherData({
this.url,
this.format,
});
PusherData.fromJson(Map<String, dynamic> json)
: format = json['format'],
url = json.containsKey('url') ? Uri.parse(json['url']) : null;
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (url != null) {
data['url'] = url.toString();
}
if (format != null) {
data['format'] = format;
}
return data;
}
}

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,38 +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.
*/
class RoomAliasInformation {
String roomId;
List<String> servers;
RoomAliasInformation.fromJson(Map<String, dynamic> json)
: roomId = json['room_id'],
servers = json['servers'].cast<String>();
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['room_id'] = roomId;
data['servers'] = servers;
return data;
}
}

View File

@ -1,3 +1,4 @@
// @dart=2.9
abstract class RoomCreationTypes {
static const String mSpace = 'm.space';
}

View File

@ -1,73 +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_api_lite.dart';
enum RoomKeysAlgorithmType { v1Curve25519AesSha2 }
extension RoomKeysAlgorithmTypeExtension on RoomKeysAlgorithmType {
String get algorithmString {
switch (this) {
case RoomKeysAlgorithmType.v1Curve25519AesSha2:
return AlgorithmTypes.megolmBackupV1Curve25519AesSha2;
default:
return null;
}
}
static RoomKeysAlgorithmType fromAlgorithmString(String s) {
switch (s) {
case AlgorithmTypes.megolmBackupV1Curve25519AesSha2:
return RoomKeysAlgorithmType.v1Curve25519AesSha2;
default:
return null;
}
}
}
class RoomKeysVersionResponse {
RoomKeysAlgorithmType algorithm;
Map<String, dynamic> authData;
int count;
String etag;
String version;
RoomKeysVersionResponse.fromJson(Map<String, dynamic> json)
: algorithm = RoomKeysAlgorithmTypeExtension.fromAlgorithmString(
json['algorithm']),
authData = json['auth_data'],
count = json['count'],
etag = json['etag']
.toString(), // synapse replies an int but docs say string?
version = json['version'];
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['algorithm'] = algorithm?.algorithmString;
data['auth_data'] = authData;
data['count'] = count;
data['etag'] = etag;
data['version'] = version;
return data;
}
}

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
@ -67,24 +68,6 @@ class RoomKeysRoom {
}
}
class RoomKeys {
Map<String, RoomKeysRoom> rooms;
RoomKeys({this.rooms}) {
rooms ??= <String, RoomKeysRoom>{};
}
RoomKeys.fromJson(Map<String, dynamic> json)
: rooms = (json['rooms'] as Map)
.map((k, v) => MapEntry(k, RoomKeysRoom.fromJson(v)));
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['rooms'] = rooms.map((k, v) => MapEntry(k, v.toJson()));
return data;
}
}
class RoomKeysUpdateResponse {
String etag;
int count;

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,95 +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 '../utils/map_copy_extension.dart';
enum RoomVersionStability { stable, unstable }
class ServerCapabilities {
MChangePassword mChangePassword;
MRoomVersions mRoomVersions;
Map<String, dynamic> customCapabilities;
ServerCapabilities.fromJson(Map<String, dynamic> json)
: mChangePassword = json['m.change_password'] != null
? MChangePassword.fromJson(json['m.change_password'])
: null,
mRoomVersions = json['m.room_versions'] != null
? MRoomVersions.fromJson(json['m.room_versions'])
: null,
customCapabilities = json.copy()
..remove('m.change_password')
..remove('m.room_versions');
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (mChangePassword != null) {
data['m.change_password'] = mChangePassword.toJson();
}
if (mRoomVersions != null) {
data['m.room_versions'] = mRoomVersions.toJson();
}
for (final entry in customCapabilities.entries) {
data[entry.key] = entry.value;
}
return data;
}
}
class MChangePassword {
bool enabled;
MChangePassword.fromJson(Map<String, dynamic> json) {
enabled = json['enabled'];
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['enabled'] = enabled;
return data;
}
}
class MRoomVersions {
String defaultVersion;
Map<String, RoomVersionStability> available;
MRoomVersions.fromJson(Map<String, dynamic> json) {
defaultVersion = json['default'];
available = (json['available'] as Map).map<String, RoomVersionStability>(
(k, v) => MapEntry(
k,
RoomVersionStability.values
.firstWhere((r) => r.toString().split('.').last == v),
),
);
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['default'] = defaultVersion;
data['available'] = available.map<String, dynamic>(
(k, v) => MapEntry(k, v.toString().split('.').last));
return data;
}
}

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,41 +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.
*/
class SupportedVersions {
List<String> versions;
Map<String, bool> unstableFeatures;
SupportedVersions.fromJson(Map<String, dynamic> json)
: versions = json['versions'].cast<String>(),
unstableFeatures =
Map<String, bool>.from(json['unstable_features'] ?? {});
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['versions'] = versions;
if (unstableFeatures != null) {
data['unstable_features'] = unstableFeatures;
}
return data;
}
}

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,46 +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.
*/
class Tag {
double order;
Tag.fromJson(Map<String, dynamic> json)
: order = double.tryParse(json['order'].toString());
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (order != null) {
data['order'] = order;
}
return data;
}
}
abstract class TagType {
static const String Favourite = 'm.favourite';
static const String LowPriority = 'm.lowpriority';
static const String ServerNotice = 'm.server_notice';
static bool isValid(String tag) => tag.startsWith('m.')
? [Favourite, LowPriority, ServerNotice].contains(tag)
: true;
}

View File

@ -1,47 +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_api.dart';
class ThirdPartyIdentifier {
ThirdPartyIdentifierMedium medium;
String address;
int validatedAt;
int addedAt;
ThirdPartyIdentifier.fromJson(Map<String, dynamic> json)
: medium = ThirdPartyIdentifierMedium.values
.firstWhere((medium) => describeEnum(medium) == json['medium']),
address = json['address'],
validatedAt = json['validated_at'],
addedAt = json['added_at'];
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['medium'] = describeEnum(medium);
data['address'] = address;
data['validated_at'] = validatedAt;
data['added_at'] = addedAt;
return data;
}
}

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,54 +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_event.dart';
class TimelineHistoryResponse {
String start;
String end;
List<MatrixEvent> chunk;
List<MatrixEvent> state;
TimelineHistoryResponse.fromJson(Map<String, dynamic> json)
: start = json['start'],
end = json['end'],
chunk = json['chunk'] != null
? (json['chunk'] as List)
.map((i) => MatrixEvent.fromJson(i))
.toList()
: null,
state = json['state'] != null
? (json['state'] as List)
.map((i) => MatrixEvent.fromJson(i))
.toList()
: null;
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (start != null) data['start'] = start;
if (end != null) data['end'] = end;
if (chunk != null) data['chunk'] = chunk.map((i) => i.toJson());
if (state != null) data['state'] = state.map((i) => i.toJson());
return data;
}
}

View File

@ -1,44 +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.
*/
class TurnServerCredentials {
String username;
String password;
List<String> uris;
num ttl;
TurnServerCredentials.fromJson(Map<String, dynamic> json)
: username = json['username'],
password = json['password'],
uris = json['uris'].cast<String>(),
ttl = json['ttl'];
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['username'] = username;
data['password'] = password;
data['uris'] = uris;
data['ttl'] = ttl;
return data;
}
}

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,42 +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 'profile.dart';
class UserSearchResult {
List<Profile> results;
bool limited;
UserSearchResult.fromJson(Map<String, dynamic> json)
: results =
(json['results'] as List).map((v) => Profile.fromJson(v)).toList(),
limited = json['limited'];
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['results'] = results.map((v) => v.toJson()).toList();
data['limited'] = limited;
return data;
}
}

View File

@ -1,73 +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 '../utils/try_get_map_extension.dart';
class WellKnownInformation {
MHomeserver mHomeserver;
MHomeserver mIdentityServer;
Map<String, dynamic> content;
factory WellKnownInformation.fromJson(Map<String, dynamic> json) =>
WellKnownInformation._fromJson(
json,
json.tryGetMap<String, dynamic>('m.homeserver'),
json.tryGetMap<String, dynamic>('m.identity_server'));
WellKnownInformation._fromJson(
Map<String, dynamic> json,
Map<String, dynamic> mHomeserverMap,
Map<String, dynamic> mIdentityServerMap)
: content = json,
mHomeserver = mHomeserverMap != null
? MHomeserver.fromJson(mHomeserverMap)
: null,
mIdentityServer = mIdentityServerMap != null
? MHomeserver.fromJson(mIdentityServerMap)
: null;
Map<String, dynamic> toJson() {
final data = content;
if (mHomeserver != null) {
data['m.homeserver'] = mHomeserver.toJson();
}
if (mIdentityServer != null) {
data['m.identity_server'] = mIdentityServer.toJson();
}
return data;
}
}
class MHomeserver {
String baseUrl;
MHomeserver.fromJson(Map<String, dynamic> json) {
baseUrl = json.tryGet<String>('base_url');
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (baseUrl != null) data['base_url'] = baseUrl;
return data;
}
}

View File

@ -1,108 +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.
*/
class WhoIsInfo {
String userId;
Map<String, DeviceInfo> devices;
WhoIsInfo.fromJson(Map<String, dynamic> json)
: userId = json['user_id'],
devices = json['devices'] != null
? (json['devices'] as Map)
.map((k, v) => MapEntry(k, DeviceInfo.fromJson(v)))
: null;
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['user_id'] = userId;
if (devices != null) {
data['devices'] = devices.map((k, v) => MapEntry(k, v.toJson()));
}
return data;
}
}
class DeviceInfo {
List<Sessions> sessions;
DeviceInfo.fromJson(Map<String, dynamic> json) {
if (json['sessions'] != null) {
sessions =
(json['sessions'] as List).map((v) => Sessions.fromJson(v)).toList();
}
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (sessions != null) {
data['sessions'] = sessions.map((v) => v.toJson()).toList();
}
return data;
}
}
class Sessions {
List<Connections> connections;
Sessions.fromJson(Map<String, dynamic> json) {
if (json['connections'] != null) {
connections = (json['connections'] as List)
.map((v) => Connections.fromJson(v))
.toList();
}
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (connections != null) {
data['connections'] = connections.map((v) => v.toJson()).toList();
}
return data;
}
}
class Connections {
String ip;
int lastSeen;
String userAgent;
Connections.fromJson(Map<String, dynamic> json) {
ip = json['ip'];
lastSeen = json['last_seen'];
userAgent = json['user_agent'];
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (ip != null) {
data['ip'] = ip;
}
if (lastSeen != null) {
data['last_seen'] = lastSeen;
}
if (userAgent != null) {
data['user_agent'] = userAgent;
}
return data;
}
}

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

20
lib/src/values.dart Normal file
View File

@ -0,0 +1,20 @@
// OpenAPI only supports real enums (modeled as enum in generated/model.dart).
// In this file, possible values are defined manually,
// for cases where other values are allowed too.
class PushRuleAction {
static final notify = 'notify';
static final dontNotify = 'dont_notify';
static final coalesce = 'coalesce';
static final setTweak = 'set_tweak';
}
class TagType {
static final favourite = 'm.favourite';
static final lowPriority = 'm.lowpriority';
static final serverNotice = 'm.server_notice';
static bool isValid(String tag) => tag.startsWith('m.')
? [favourite, lowPriority, serverNotice].contains(tag)
: true;
}

View File

@ -4,7 +4,7 @@ version: 0.3.3
homepage: https://famedly.com
environment:
sdk: ">=2.10.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"
dependencies:
http: ^0.13.0

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
@ -132,7 +133,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
final wellKnownInformation = await matrixApi.getWellknown();
expect(wellKnownInformation.mHomeserver.baseUrl,
'https://fakeserver.notexisting');
Uri.parse('https://fakeserver.notexisting'));
expect(wellKnownInformation.toJson(), {
'm.homeserver': {'base_url': 'https://fakeserver.notexisting'},
'm.identity_server': {
@ -146,14 +147,15 @@ void main() {
test('getLoginTypes', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
final loginTypes = await matrixApi.getLoginFlows();
expect(loginTypes.flows.first.type, 'm.login.password');
expect(loginTypes.first.type, 'm.login.password');
expect(FakeMatrixApi.api['GET']['/client/r0/login']({}),
loginTypes.toJson());
{'flows': loginTypes.map((x) => x.toJson()).toList()});
matrixApi.homeserver = null;
});
test('login', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
final loginResponse = await matrixApi.login(
LoginType.mLoginPassword,
identifier: AuthenticationUserIdentifier(user: 'username'),
);
expect(FakeMatrixApi.api['POST']['/client/r0/login']({}),
@ -175,7 +177,7 @@ void main() {
test('register', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
final registerResponse =
await matrixApi.register(kind: 'guest', username: 'test');
await matrixApi.register(kind: AccountKind.guest, username: 'test');
expect(FakeMatrixApi.api['POST']['/client/r0/register?kind=guest']({}),
registerResponse.toJson());
matrixApi.homeserver = null;
@ -319,7 +321,7 @@ void main() {
final response = await matrixApi.unbind3pidFromAccount(
'alice@example.com',
ThirdPartyIdentifierMedium.email,
'https://example.com',
idServer: 'https://example.com',
);
expect(response, IdServerUnbindResult.success);
matrixApi.homeserver = matrixApi.accessToken = null;
@ -355,10 +357,10 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234';
final response = await matrixApi.getTokenOwner();
expect(response, 'alice@example.com');
expect(response.userId, 'alice@example.com');
matrixApi.homeserver = matrixApi.accessToken = null;
});
test('getServerCapabilities', () async {
test('getCapabilities', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234';
final response = await matrixApi.getCapabilities();
@ -392,7 +394,7 @@ void main() {
timeline: StateFilter(),
accountData: StateFilter(limit: 10, types: ['type1']),
),
presence: EventFilter(
presence: StateFilter(
limit: 10,
senders: ['@alice:example.com'],
types: ['type1'],
@ -412,6 +414,7 @@ void main() {
'rooms': ['!1234'],
'ephemeral': {
'limit': 10,
'senders': ['@alice:example.com'],
'types': ['type1'],
'not_rooms': ['!1234'],
'not_senders': ['@bob:example.com'],
@ -430,6 +433,7 @@ void main() {
},
'presence': {
'limit': 10,
'senders': ['@alice:example.com'],
'types': ['type1'],
'not_rooms': ['!1234'],
'not_senders': ['@bob:example.com']
@ -573,7 +577,7 @@ void main() {
expect(
FakeMatrixApi.api['GET'][
'/client/r0/rooms/!localpart%3Aserver.abc/messages?from=1234&dir=b&to=1234&limit=10&filter=%7B%22lazy_load_members%22%3Atrue%7D'](
'/client/r0/rooms/!localpart%3Aserver.abc/messages?from=1234&to=1234&dir=b&limit=10&filter=%7B%22lazy_load_members%22%3Atrue%7D'](
{}) as Map,
timelineHistoryResponse.toJson());
@ -584,7 +588,7 @@ void main() {
matrixApi.accessToken = '1234';
final eventId = await matrixApi.setRoomStateWithKey(
'!localpart:server.abc', 'm.room.avatar', {'url': 'mxc://1234'});
'!localpart:server.abc', 'm.room.avatar', '', {'url': 'mxc://1234'});
expect(eventId, 'YUwRidLecu:example.com');
@ -634,7 +638,7 @@ void main() {
roomVersion: '2',
creationContent: {},
initialState: [],
preset: CreateRoomPreset.public_chat,
preset: CreateRoomPreset.publicChat,
isDirect: false,
powerLevelContentOverride: {},
);
@ -695,12 +699,11 @@ void main() {
matrixApi.homeserver = matrixApi.accessToken = null;
});
test('inviteToRoom', () async {
test('inviteUser', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234';
await matrixApi.inviteToRoom(
'!localpart:example.com', '@bob:example.com');
await matrixApi.inviteUser('!localpart:example.com', '@bob:example.com');
matrixApi.homeserver = matrixApi.accessToken = null;
});
@ -711,12 +714,14 @@ void main() {
final roomId = '!localpart:example.com';
final response = await matrixApi.joinRoomById(
roomId,
thirdPidSignedSender: '@bob:example.com',
thirdPidSignedmxid: '@alice:example.com',
thirdPidSignedToken: '1234',
thirdPidSignedSiganture: {
'example.org': {'ed25519:0': 'some9signature'}
},
thirdPartySigned: ThirdPartySigned(
sender: '@bob:example.com',
mxid: '@alice:example.com',
token: '1234',
signatures: {
'example.org': {'ed25519:0': 'some9signature'}
},
),
);
expect(response, roomId);
@ -729,13 +734,15 @@ void main() {
final roomId = '!localpart:example.com';
final response = await matrixApi.joinRoom(
roomId,
servers: ['example.com', 'example.abc'],
thirdPidSignedSender: '@bob:example.com',
thirdPidSignedmxid: '@alice:example.com',
thirdPidSignedToken: '1234',
thirdPidSignedSiganture: {
'example.org': {'ed25519:0': 'some9signature'}
},
serverName: ['example.com', 'example.abc'],
thirdPartySigned: ThirdPartySigned(
sender: '@bob:example.com',
mxid: '@alice:example.com',
token: '1234',
signatures: {
'example.org': {'ed25519:0': 'some9signature'}
},
),
);
expect(response, roomId);
@ -836,7 +843,9 @@ void main() {
limit: 10,
since: '1234',
server: 'example.com',
genericSearchTerm: 'test',
filter: PublicRoomQueryFilter(
genericSearchTerm: 'test',
),
includeAllNetworks: false,
thirdPartyInstanceId: 'id',
);
@ -939,7 +948,9 @@ void main() {
await matrixApi.postReceipt(
'!localpart:example.com',
ReceiptType.mRead,
'\$1234:example.com',
{},
);
matrixApi.homeserver = matrixApi.accessToken = null;
@ -951,7 +962,7 @@ void main() {
await matrixApi.setReadMarker(
'!localpart:example.com',
'\$1234:example.com',
readReceiptLocationEventId: '\$1234:example.com',
mRead: '\$1234:example.com',
);
matrixApi.homeserver = matrixApi.accessToken = null;
@ -984,12 +995,14 @@ void main() {
});
test('upload', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
final response = await matrixApi.uploadContent(Uint8List(0), 'file.jpeg');
matrixApi.accessToken = '1234';
final response =
await matrixApi.uploadContent(Uint8List(0), filename: 'file.jpeg');
expect(response, 'mxc://example.com/AQwafuaFswefuhsfAFAgsw');
var throwsException = false;
try {
await matrixApi.uploadContent(Uint8List(0), 'file.jpg');
} on MatrixException catch (_) {
await matrixApi.uploadContent(Uint8List(0), filename: 'file.jpg');
} catch (_) {
throwsException = true;
}
expect(throwsException, true);
@ -1010,12 +1023,12 @@ void main() {
matrixApi.homeserver = matrixApi.accessToken = null;
});
test('requestMaxUploadSize', () async {
test('getConfig', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234';
final response = await matrixApi.getConfig();
expect(response, 50000000);
expect(response.mUploadSize, 50000000);
matrixApi.homeserver = matrixApi.accessToken = null;
});
@ -1243,12 +1256,12 @@ void main() {
await matrixApi.postPusher(
Pusher(
'1234',
'app.id',
'appDisplayName',
'deviceDisplayName',
'en',
PusherData(
pushkey: '1234',
appId: 'app.id',
appDisplayName: 'appDisplayName',
deviceDisplayName: 'deviceDisplayName',
lang: 'en',
data: PusherData(
format: 'event_id_only', url: Uri.parse('https://matrix.org')),
profileTag: 'tag',
kind: 'http',
@ -1321,11 +1334,11 @@ void main() {
before: '1',
after: '2',
conditions: [
PushConditions(
'event_match',
PushCondition(
kind: 'event_match',
key: 'key',
pattern: 'pattern',
isOperator: '+',
is$: '+',
)
],
pattern: 'pattern',
@ -1374,7 +1387,7 @@ void main() {
'global',
PushRuleKind.content,
'nocake',
[PushRuleAction.dont_notify],
[PushRuleAction.dontNotify],
);
matrixApi.homeserver = matrixApi.accessToken = null;
@ -1383,7 +1396,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234';
await matrixApi.search({});
await matrixApi.search(Categories());
matrixApi.homeserver = matrixApi.accessToken = null;
});
@ -1509,7 +1522,7 @@ void main() {
limit: 10, filter: '{}');
expect(
FakeMatrixApi.api['GET']
['/client/r0/rooms/1234/context/1234?filter=%7B%7D&limit=10']({}),
['/client/r0/rooms/1234/context/1234?limit=10&filter=%7B%7D']({}),
response.toJson(),
);
@ -1522,8 +1535,8 @@ void main() {
await matrixApi.reportContent(
'1234',
'1234',
'test',
-100,
reason: 'test',
score: -100,
);
matrixApi.homeserver = matrixApi.accessToken = null;
@ -1606,7 +1619,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234';
final response = await matrixApi.requestOpenIdToken('1234');
final response = await matrixApi.requestOpenIdToken('1234', {});
expect(
FakeMatrixApi.api['POST']
['/client/r0/user/1234/openid/request_token']({}),
@ -1623,39 +1636,39 @@ void main() {
matrixApi.homeserver = matrixApi.accessToken = null;
});
test('createRoomKeysBackup', () async {
test('postRoomKeysVersion', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234';
final algorithm = RoomKeysAlgorithmType.v1Curve25519AesSha2;
final algorithm = BackupAlgorithm.mMegolmBackupV1Curve25519AesSha2;
final authData = <String, dynamic>{
'public_key': 'GXYaxqhNhUK28zUdxOmEsFRguz+PzBsDlTLlF0O0RkM',
'signatures': {},
};
final ret = await matrixApi.createRoomKeysBackup(algorithm, authData);
final ret = await matrixApi.postRoomKeysVersion(algorithm, authData);
expect(
FakeMatrixApi.api['POST']
['/client/unstable/room_keys/version']({})['version'],
ret);
});
test('getRoomKeysBackup', () async {
test('getRoomKeysVersionCurrent', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234';
final ret = await matrixApi.getRoomKeysBackup();
final ret = await matrixApi.getRoomKeysVersionCurrent();
expect(FakeMatrixApi.api['GET']['/client/unstable/room_keys/version']({}),
ret.toJson());
});
test('updateRoomKeysBackup', () async {
test('putRoomKeysVersion', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234';
final algorithm = RoomKeysAlgorithmType.v1Curve25519AesSha2;
final algorithm = BackupAlgorithm.mMegolmBackupV1Curve25519AesSha2;
final authData = <String, dynamic>{
'public_key': 'GXYaxqhNhUK28zUdxOmEsFRguz+PzBsDlTLlF0O0RkM',
'signatures': {},
};
await matrixApi.updateRoomKeysBackup('5', algorithm, authData);
await matrixApi.putRoomKeysVersion('5', algorithm, authData);
});
test('deleteRoomKeysBackup', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
@ -1663,13 +1676,13 @@ void main() {
await matrixApi.deleteRoomKeysBackup('5');
});
test('storeRoomKeysSingleKey', () async {
test('postRoomKeysKeyRoomIdSessionId', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234';
final roomId = '!726s6s6q:example.com';
final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
final session = RoomKeysSingleKey.fromJson({
final session = KeyBackupData.fromJson({
'first_message_index': 0,
'forwarded_count': 0,
'is_verified': true,
@ -1680,7 +1693,7 @@ void main() {
'mac': 'QzKV/fgAs4U',
},
});
final ret = await matrixApi.storeRoomKeysSingleKey(
final ret = await matrixApi.postRoomKeysKeyRoomIdSessionId(
roomId, sessionId, '5', session);
expect(
FakeMatrixApi.api['PUT'][
@ -1712,13 +1725,13 @@ void main() {
'/client/unstable/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5']({}),
ret.toJson());
});
test('storeRoomKeysRoom', () async {
test('postRoomKeysKeyRoomId', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234';
final roomId = '!726s6s6q:example.com';
final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
final session = RoomKeysRoom.fromJson({
final session = RoomKeyBackup.fromJson({
'sessions': {
sessionId: {
'first_message_index': 0,
@ -1733,7 +1746,7 @@ void main() {
},
},
});
final ret = await matrixApi.storeRoomKeysRoom(roomId, '5', session);
final ret = await matrixApi.postRoomKeysKeyRoomId(roomId, '5', session);
expect(
FakeMatrixApi.api['PUT'][
'/client/unstable/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}?version=5']({}),
@ -1761,7 +1774,7 @@ void main() {
'/client/unstable/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}?version=5']({}),
ret.toJson());
});
test('storeRoomKeys', () async {
test('postRoomKeysKey', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234';
@ -1786,7 +1799,7 @@ void main() {
},
},
});
final ret = await matrixApi.storeRoomKeys('5', session);
final ret = await matrixApi.postRoomKeysKey('5', session);
expect(
FakeMatrixApi.api['PUT']
['/client/unstable/room_keys/keys?version=5']({}),

View File

@ -1,3 +1,4 @@
// @dart=2.9
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH