refactor: External matrix api
This commit is contained in:
parent
41df79c6ca
commit
e450a09fb5
|
|
@ -22,9 +22,7 @@ import 'dart:async';
|
|||
import 'package:pedantic/pedantic.dart';
|
||||
|
||||
import '../famedlysdk.dart';
|
||||
import '../matrix_api.dart';
|
||||
import '../src/utils/run_in_root.dart';
|
||||
import '../matrix_api/utils/logs.dart';
|
||||
import 'cross_signing.dart';
|
||||
import 'key_manager.dart';
|
||||
import 'key_verification_manager.dart';
|
||||
|
|
|
|||
|
|
@ -24,13 +24,9 @@ import './encryption.dart';
|
|||
import './utils/outbound_group_session.dart';
|
||||
import './utils/session_key.dart';
|
||||
import '../famedlysdk.dart';
|
||||
import '../matrix_api.dart';
|
||||
import '../src/database/database.dart';
|
||||
import '../matrix_api/utils/logs.dart';
|
||||
import '../src/utils/run_in_background.dart';
|
||||
import '../src/utils/run_in_root.dart';
|
||||
import '../matrix_api/utils/try_get_map_extension.dart';
|
||||
import '../matrix_api/utils/map_copy_extension.dart';
|
||||
|
||||
const MEGOLM_KEY = EventTypes.MegolmBackup;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,12 +20,10 @@ import 'dart:convert';
|
|||
|
||||
import 'package:canonical_json/canonical_json.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:famedlysdk/matrix_api.dart';
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
import 'package:pedantic/pedantic.dart';
|
||||
|
||||
import '../encryption/utils/json_signature_check_extension.dart';
|
||||
import '../matrix_api/utils/logs.dart';
|
||||
import 'encryption.dart';
|
||||
import 'utils/olm_session.dart';
|
||||
import '../src/utils/run_in_root.dart';
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@ import 'package:encrypt/encrypt.dart';
|
|||
import 'package:password_hash/password_hash.dart';
|
||||
|
||||
import '../famedlysdk.dart';
|
||||
import '../matrix_api.dart';
|
||||
import '../src/database/database.dart';
|
||||
import '../matrix_api/utils/logs.dart';
|
||||
import '../src/utils/run_in_background.dart';
|
||||
import 'encryption.dart';
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import '../encryption.dart';
|
|||
import '../ssss.dart';
|
||||
import '../key_manager.dart';
|
||||
import '../../famedlysdk.dart';
|
||||
import '../../matrix_api/utils/logs.dart';
|
||||
|
||||
enum BootstrapState {
|
||||
/// Is loading.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import 'package:canonical_json/canonical_json.dart';
|
||||
import 'package:famedlysdk/matrix_api/utils/logs.dart';
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
|
||||
import '../../famedlysdk.dart';
|
||||
|
||||
extension JsonSignatureCheckExtension on Map<String, dynamic> {
|
||||
/// Checks the signature of a signed json object.
|
||||
bool checkJsonSignature(String key, String userId, String deviceId) {
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ import 'package:olm/olm.dart' as olm;
|
|||
import 'package:pedantic/pedantic.dart';
|
||||
|
||||
import '../../famedlysdk.dart';
|
||||
import '../../matrix_api.dart';
|
||||
import '../../matrix_api/utils/logs.dart';
|
||||
import '../encryption.dart';
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
|
||||
import '../../famedlysdk.dart';
|
||||
import '../../src/database/database.dart' show DbOlmSessions;
|
||||
import '../../matrix_api/utils/logs.dart';
|
||||
|
||||
class OlmSession {
|
||||
String identityKey;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ import 'dart:convert';
|
|||
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
|
||||
import '../../famedlysdk.dart';
|
||||
import '../../src/database/database.dart' show DbOutboundGroupSession;
|
||||
import '../../matrix_api/utils/logs.dart';
|
||||
|
||||
class OutboundGroupSession {
|
||||
/// The devices is a map from user id to device id to if the device is blocked.
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import 'package:olm/olm.dart' as olm;
|
|||
|
||||
import '../../famedlysdk.dart';
|
||||
import '../../src/database/database.dart' show DbInboundGroupSession;
|
||||
import '../../matrix_api/utils/logs.dart';
|
||||
|
||||
class SessionKey {
|
||||
/// The raw json content of the key
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
library famedlysdk;
|
||||
|
||||
export 'matrix_api.dart';
|
||||
export 'package:matrix_api_lite/matrix_api_lite.dart';
|
||||
export 'src/utils/room_update.dart';
|
||||
export 'src/utils/event_update.dart';
|
||||
export 'src/utils/device_keys_list.dart';
|
||||
|
|
|
|||
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
library matrix_api;
|
||||
|
||||
export 'matrix_api/matrix_api.dart';
|
||||
export 'matrix_api/utils/logs.dart';
|
||||
export 'matrix_api/utils/map_copy_extension.dart';
|
||||
export 'matrix_api/utils/try_get_map_extension.dart';
|
||||
export 'matrix_api/model/algorithm_types.dart';
|
||||
export 'matrix_api/model/basic_event.dart';
|
||||
export 'matrix_api/model/basic_event_with_sender.dart';
|
||||
export 'matrix_api/model/basic_room_event.dart';
|
||||
export 'matrix_api/model/device.dart';
|
||||
export 'matrix_api/model/event_context.dart';
|
||||
export 'matrix_api/model/event_types.dart';
|
||||
export 'matrix_api/model/events_sync_update.dart';
|
||||
export 'matrix_api/model/filter.dart';
|
||||
export 'matrix_api/model/keys_query_response.dart';
|
||||
export 'matrix_api/model/login_response.dart';
|
||||
export 'matrix_api/model/login_types.dart';
|
||||
export 'matrix_api/model/matrix_connection_exception.dart';
|
||||
export 'matrix_api/model/matrix_event.dart';
|
||||
export 'matrix_api/model/matrix_exception.dart';
|
||||
export 'matrix_api/model/matrix_keys.dart';
|
||||
export 'matrix_api/model/message_types.dart';
|
||||
export 'matrix_api/model/notifications_query_response.dart';
|
||||
export 'matrix_api/model/one_time_keys_claim_response.dart';
|
||||
export 'matrix_api/model/open_graph_data.dart';
|
||||
export 'matrix_api/model/open_id_credentials.dart';
|
||||
export 'matrix_api/model/presence.dart';
|
||||
export 'matrix_api/model/presence_content.dart';
|
||||
export 'matrix_api/model/profile.dart';
|
||||
export 'matrix_api/model/public_rooms_response.dart';
|
||||
export 'matrix_api/model/push_rule_set.dart';
|
||||
export 'matrix_api/model/pusher.dart';
|
||||
export 'matrix_api/model/request_token_response.dart';
|
||||
export 'matrix_api/model/room_alias_informations.dart';
|
||||
export 'matrix_api/model/room_keys_info.dart';
|
||||
export 'matrix_api/model/room_keys_keys.dart';
|
||||
export 'matrix_api/model/room_summary.dart';
|
||||
export 'matrix_api/model/server_capabilities.dart';
|
||||
export 'matrix_api/model/stripped_state_event.dart';
|
||||
export 'matrix_api/model/supported_protocol.dart';
|
||||
export 'matrix_api/model/supported_versions.dart';
|
||||
export 'matrix_api/model/sync_update.dart';
|
||||
export 'matrix_api/model/tag.dart';
|
||||
export 'matrix_api/model/third_party_identifier.dart';
|
||||
export 'matrix_api/model/third_party_location.dart';
|
||||
export 'matrix_api/model/third_party_user.dart';
|
||||
export 'matrix_api/model/timeline_history_response.dart';
|
||||
export 'matrix_api/model/turn_server_credentials.dart';
|
||||
export 'matrix_api/model/upload_key_signatures_response.dart';
|
||||
export 'matrix_api/model/user_search_result.dart';
|
||||
export 'matrix_api/model/well_known_informations.dart';
|
||||
export 'matrix_api/model/who_is_info.dart';
|
||||
export 'matrix_api/model/auth/authentication_data.dart';
|
||||
export 'matrix_api/model/auth/authentication_identifier.dart';
|
||||
export 'matrix_api/model/auth/authentication_password.dart';
|
||||
export 'matrix_api/model/auth/authentication_phone_identifier.dart';
|
||||
export 'matrix_api/model/auth/authentication_recaptcha.dart';
|
||||
export 'matrix_api/model/auth/authentication_third_party_identifier.dart';
|
||||
export 'matrix_api/model/auth/authentication_three_pid_creds.dart';
|
||||
export 'matrix_api/model/auth/authentication_token.dart';
|
||||
export 'matrix_api/model/auth/authentication_types.dart';
|
||||
export 'matrix_api/model/auth/authentication_user_identifier.dart';
|
||||
export 'matrix_api/model/events/secret_storage_default_key_content.dart';
|
||||
export 'matrix_api/model/events/secret_storage_key_content.dart';
|
||||
export 'matrix_api/model/events/tombstone_content.dart';
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
abstract class AlgorithmTypes {
|
||||
static const String olmV1Curve25519AesSha2 = 'm.olm.v1.curve25519-aes-sha2';
|
||||
static const String megolmV1AesSha2 = 'm.megolm.v1.aes-sha2';
|
||||
static const String secretStorageV1AesHmcSha2 =
|
||||
'm.secret_storage.v1.aes-hmac-sha2';
|
||||
static const String megolmBackupV1Curve25519AesSha2 =
|
||||
'm.megolm_backup.v1.curve25519-aes-sha2';
|
||||
static const String pbkdf2 = 'm.pbkdf2';
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class AuthenticationData {
|
||||
String type;
|
||||
String session;
|
||||
|
||||
AuthenticationData({this.type, this.session});
|
||||
|
||||
AuthenticationData.fromJson(Map<String, dynamic> json) {
|
||||
type = json['type'];
|
||||
session = json['session'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (type != null) data['type'] = type;
|
||||
if (session != null) data['session'] = session;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class AuthenticationIdentifier {
|
||||
String type;
|
||||
|
||||
AuthenticationIdentifier({this.type});
|
||||
|
||||
AuthenticationIdentifier.fromJson(Map<String, dynamic> json) {
|
||||
type = json['type'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['type'] = type;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:famedlysdk/matrix_api/model/auth/authentication_user_identifier.dart';
|
||||
|
||||
import 'authentication_data.dart';
|
||||
import 'authentication_identifier.dart';
|
||||
import 'authentication_phone_identifier.dart';
|
||||
import 'authentication_third_party_identifier.dart';
|
||||
import 'authentication_types.dart';
|
||||
|
||||
class AuthenticationPassword extends AuthenticationData {
|
||||
String user;
|
||||
String password;
|
||||
|
||||
/// You may want to cast this as [AuthenticationUserIdentifier] or other
|
||||
/// Identifier classes extending AuthenticationIdentifier.
|
||||
AuthenticationIdentifier identifier;
|
||||
|
||||
AuthenticationPassword(
|
||||
{String session, this.password, this.user, this.identifier})
|
||||
: super(
|
||||
type: AuthenticationTypes.password,
|
||||
session: session,
|
||||
);
|
||||
|
||||
AuthenticationPassword.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
user = json['user'];
|
||||
password = json['password'];
|
||||
identifier = AuthenticationIdentifier.fromJson(json['identifier']);
|
||||
switch (identifier.type) {
|
||||
case AuthenticationIdentifierTypes.userId:
|
||||
identifier = AuthenticationUserIdentifier.fromJson(json['identifier']);
|
||||
break;
|
||||
case AuthenticationIdentifierTypes.phone:
|
||||
identifier = AuthenticationPhoneIdentifier.fromJson(json['identifier']);
|
||||
break;
|
||||
case AuthenticationIdentifierTypes.thirdParty:
|
||||
identifier =
|
||||
AuthenticationThirdPartyIdentifier.fromJson(json['identifier']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
if (user != null) data['user'] = user;
|
||||
data['password'] = password;
|
||||
switch (identifier.type) {
|
||||
case AuthenticationIdentifierTypes.userId:
|
||||
data['identifier'] =
|
||||
(identifier as AuthenticationUserIdentifier).toJson();
|
||||
break;
|
||||
case AuthenticationIdentifierTypes.phone:
|
||||
data['identifier'] =
|
||||
(identifier as AuthenticationPhoneIdentifier).toJson();
|
||||
break;
|
||||
case AuthenticationIdentifierTypes.thirdParty:
|
||||
data['identifier'] =
|
||||
(identifier as AuthenticationThirdPartyIdentifier).toJson();
|
||||
break;
|
||||
default:
|
||||
data['identifier'] = identifier.toJson();
|
||||
break;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'authentication_identifier.dart';
|
||||
import 'authentication_types.dart';
|
||||
|
||||
class AuthenticationPhoneIdentifier extends AuthenticationIdentifier {
|
||||
String country;
|
||||
String phone;
|
||||
|
||||
AuthenticationPhoneIdentifier({this.country, this.phone})
|
||||
: super(type: AuthenticationIdentifierTypes.phone);
|
||||
|
||||
AuthenticationPhoneIdentifier.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
country = json['country'];
|
||||
phone = json['phone'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['country'] = country;
|
||||
data['phone'] = phone;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'authentication_data.dart';
|
||||
import 'authentication_types.dart';
|
||||
|
||||
class AuthenticationRecaptcha extends AuthenticationData {
|
||||
String response;
|
||||
|
||||
AuthenticationRecaptcha({String session, this.response})
|
||||
: super(
|
||||
type: AuthenticationTypes.recaptcha,
|
||||
session: session,
|
||||
);
|
||||
|
||||
AuthenticationRecaptcha.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
response = json['response'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['response'] = response;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'authentication_identifier.dart';
|
||||
import 'authentication_types.dart';
|
||||
|
||||
class AuthenticationThirdPartyIdentifier extends AuthenticationIdentifier {
|
||||
String medium;
|
||||
String address;
|
||||
|
||||
AuthenticationThirdPartyIdentifier({this.medium, this.address})
|
||||
: super(type: AuthenticationIdentifierTypes.thirdParty);
|
||||
|
||||
AuthenticationThirdPartyIdentifier.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
medium = json['medium'];
|
||||
address = json['address'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['medium'] = medium;
|
||||
data['address'] = address;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'authentication_data.dart';
|
||||
|
||||
/// For email based identity:
|
||||
/// https://matrix.org/docs/spec/client_server/r0.6.1#email-based-identity-homeserver
|
||||
/// Or phone number based identity:
|
||||
/// https://matrix.org/docs/spec/client_server/r0.6.1#phone-number-msisdn-based-identity-homeserver
|
||||
class AuthenticationThreePidCreds extends AuthenticationData {
|
||||
List<ThreepidCreds> threepidCreds;
|
||||
|
||||
AuthenticationThreePidCreds({String session, String type, this.threepidCreds})
|
||||
: super(
|
||||
type: type,
|
||||
session: session,
|
||||
);
|
||||
|
||||
AuthenticationThreePidCreds.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
if (json['threepidCreds'] != null) {
|
||||
threepidCreds = (json['threepidCreds'] as List)
|
||||
.map((item) => ThreepidCreds.fromJson(item))
|
||||
.toList();
|
||||
}
|
||||
|
||||
// This is so extremly stupid... kill it with fire!
|
||||
if (json['threepid_creds'] != null) {
|
||||
threepidCreds = (json['threepid_creds'] as List)
|
||||
.map((item) => ThreepidCreds.fromJson(item))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['threepidCreds'] = threepidCreds.map((t) => t.toJson()).toList();
|
||||
// Help me! I'm prisoned in a developer factory against my will,
|
||||
// where we are forced to work with json like this!!
|
||||
data['threepid_creds'] = threepidCreds.map((t) => t.toJson()).toList();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class ThreepidCreds {
|
||||
String sid;
|
||||
String clientSecret;
|
||||
String idServer;
|
||||
String idAccessToken;
|
||||
|
||||
ThreepidCreds(
|
||||
{this.sid, this.clientSecret, this.idServer, this.idAccessToken});
|
||||
|
||||
ThreepidCreds.fromJson(Map<String, dynamic> json) {
|
||||
sid = json['sid'];
|
||||
clientSecret = json['client_secret'];
|
||||
idServer = json['id_server'];
|
||||
idAccessToken = json['id_access_token'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['sid'] = sid;
|
||||
data['client_secret'] = clientSecret;
|
||||
data['id_server'] = idServer;
|
||||
data['id_access_token'] = idAccessToken;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'authentication_data.dart';
|
||||
import 'authentication_types.dart';
|
||||
|
||||
class AuthenticationToken extends AuthenticationData {
|
||||
String token;
|
||||
String txnId;
|
||||
|
||||
AuthenticationToken({String session, this.token, this.txnId})
|
||||
: super(
|
||||
type: AuthenticationTypes.token,
|
||||
session: session,
|
||||
);
|
||||
|
||||
AuthenticationToken.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
token = json['token'];
|
||||
txnId = json['txn_id'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['token'] = token;
|
||||
data['txn_id'] = txnId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
abstract class AuthenticationTypes {
|
||||
static const String password = 'm.login.password';
|
||||
static const String recaptcha = 'm.login.recaptcha';
|
||||
static const String token = 'm.login.token';
|
||||
static const String oauth2 = 'm.login.oauth2';
|
||||
static const String sso = 'm.login.sso';
|
||||
static const String emailIdentity = 'm.login.email.identity';
|
||||
static const String msisdn = 'm.login.msisdn';
|
||||
static const String dummy = 'm.login.dummy';
|
||||
}
|
||||
|
||||
abstract class AuthenticationIdentifierTypes {
|
||||
static const String userId = 'm.id.user';
|
||||
static const String thirdParty = 'm.id.thirdparty';
|
||||
static const String phone = 'm.id.phone';
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'authentication_identifier.dart';
|
||||
import 'authentication_types.dart';
|
||||
|
||||
class AuthenticationUserIdentifier extends AuthenticationIdentifier {
|
||||
String user;
|
||||
|
||||
AuthenticationUserIdentifier({this.user})
|
||||
: super(type: AuthenticationIdentifierTypes.userId);
|
||||
|
||||
AuthenticationUserIdentifier.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
user = json['user'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['user'] = user;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import '../utils/map_copy_extension.dart';
|
||||
|
||||
class BasicEvent {
|
||||
String type;
|
||||
Map<String, dynamic> content;
|
||||
|
||||
BasicEvent({
|
||||
this.type,
|
||||
this.content,
|
||||
});
|
||||
|
||||
BasicEvent.fromJson(Map<String, dynamic> json) {
|
||||
type = json['type'];
|
||||
content = (json['content'] as Map<String, dynamic>).copy();
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['type'] = type;
|
||||
data['content'] = content;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'basic_event.dart';
|
||||
|
||||
class BasicEventWithSender extends BasicEvent {
|
||||
String senderId;
|
||||
|
||||
BasicEventWithSender();
|
||||
|
||||
BasicEventWithSender.fromJson(Map<String, dynamic> json) {
|
||||
final basicEvent = BasicEvent.fromJson(json);
|
||||
type = basicEvent.type;
|
||||
content = basicEvent.content;
|
||||
senderId = json['sender'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['sender'] = senderId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'basic_event.dart';
|
||||
|
||||
class BasicRoomEvent extends BasicEvent {
|
||||
String roomId;
|
||||
|
||||
BasicRoomEvent({
|
||||
this.roomId,
|
||||
Map<String, dynamic> content,
|
||||
String type,
|
||||
}) : super(
|
||||
content: content,
|
||||
type: type,
|
||||
);
|
||||
|
||||
BasicRoomEvent.fromJson(Map<String, dynamic> json) {
|
||||
final basicEvent = BasicEvent.fromJson(json);
|
||||
content = basicEvent.content;
|
||||
type = basicEvent.type;
|
||||
roomId = json['room_id'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
if (roomId != null) data['room_id'] = roomId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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'];
|
||||
if (json['events_after'] != null) {
|
||||
eventsAfter = <MatrixEvent>[];
|
||||
json['events_after'].forEach((v) {
|
||||
eventsAfter.add(MatrixEvent.fromJson(v));
|
||||
});
|
||||
}
|
||||
event = json['event'] != null ? MatrixEvent.fromJson(json['event']) : null;
|
||||
if (json['events_before'] != null) {
|
||||
eventsBefore = <MatrixEvent>[];
|
||||
json['events_before'].forEach((v) {
|
||||
eventsBefore.add(MatrixEvent.fromJson(v));
|
||||
});
|
||||
}
|
||||
start = json['start'];
|
||||
if (json['state'] != null) {
|
||||
state = <MatrixEvent>[];
|
||||
json['state'].forEach((v) {
|
||||
state.add(MatrixEvent.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
abstract class EventTypes {
|
||||
// Room timeline and state event types
|
||||
static const String Message = 'm.room.message';
|
||||
static const String Sticker = 'm.sticker';
|
||||
static const String Reaction = 'm.reaction';
|
||||
static const String Redaction = 'm.room.redaction';
|
||||
static const String RoomAliases = 'm.room.aliases';
|
||||
static const String RoomCanonicalAlias = 'm.room.canonical_alias';
|
||||
static const String RoomCreate = 'm.room.create';
|
||||
static const String RoomJoinRules = 'm.room.join_rules';
|
||||
static const String RoomMember = 'm.room.member';
|
||||
static const String RoomPowerLevels = 'm.room.power_levels';
|
||||
static const String RoomName = 'm.room.name';
|
||||
static const String RoomPinnedEvents = 'm.room.pinned_events';
|
||||
static const String RoomTopic = 'm.room.topic';
|
||||
static const String RoomAvatar = 'm.room.avatar';
|
||||
static const String RoomTombstone = 'm.room.tombstone';
|
||||
static const String GuestAccess = 'm.room.guest_access';
|
||||
static const String HistoryVisibility = 'm.room.history_visibility';
|
||||
static const String Encryption = 'm.room.encryption';
|
||||
static const String Encrypted = 'm.room.encrypted';
|
||||
static const String CallInvite = 'm.call.invite';
|
||||
static const String CallAnswer = 'm.call.answer';
|
||||
static const String CallCandidates = 'm.call.candidates';
|
||||
static const String CallHangup = 'm.call.hangup';
|
||||
static const String Unknown = 'm.unknown';
|
||||
|
||||
// To device event types
|
||||
static const String RoomKey = 'm.room_key';
|
||||
static const String ForwardedRoomKey = 'm.forwarded_room_key';
|
||||
static const String RoomKeyRequest = 'm.room_key_request';
|
||||
static const String KeyVerificationRequest = 'm.key.verification.request';
|
||||
static const String KeyVerificationStart = 'm.key.verification.start';
|
||||
static const String KeyVerificationDone = 'm.key.verification.done';
|
||||
static const String KeyVerificationCancel = 'm.key.verification.cancel';
|
||||
static const String KeyVerificationAccept = 'm.key.verification.accept';
|
||||
static const String SecretRequest = 'm.secret.request';
|
||||
static const String SecretSend = 'm.secret.send';
|
||||
static const String CrossSigningSelfSigning = 'm.cross_signing.self_signing';
|
||||
static const String CrossSigningUserSigning = 'm.cross_signing.user_signing';
|
||||
static const String CrossSigningMasterKey = 'm.cross_signing.master';
|
||||
static const String MegolmBackup = 'm.megolm_backup.v1';
|
||||
static const String SecretStorageDefaultKey = 'm.secret_storage.default_key';
|
||||
static String secretStorageKey(String keyId) => 'm.secret_storage.key.$keyId';
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
import 'package:famedlysdk/matrix_api/model/basic_event.dart';
|
||||
import '../../utils/try_get_map_extension.dart';
|
||||
|
||||
extension SecretStorageDefaultKeyContentBasicEventExtension on BasicEvent {
|
||||
SecretStorageDefaultKeyContent get parsedSecretStorageDefaultKeyContent =>
|
||||
SecretStorageDefaultKeyContent.fromJson(content);
|
||||
}
|
||||
|
||||
class SecretStorageDefaultKeyContent {
|
||||
String key;
|
||||
|
||||
SecretStorageDefaultKeyContent();
|
||||
|
||||
SecretStorageDefaultKeyContent.fromJson(Map<String, dynamic> json)
|
||||
: key = json.tryGet<String>('key');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (key != null) data['key'] = key;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
import 'package:famedlysdk/matrix_api/model/basic_event.dart';
|
||||
import '../../utils/try_get_map_extension.dart';
|
||||
|
||||
extension SecretStorageKeyContentBasicEventExtension on BasicEvent {
|
||||
SecretStorageKeyContent get parsedSecretStorageKeyContent =>
|
||||
SecretStorageKeyContent.fromJson(content);
|
||||
}
|
||||
|
||||
class SecretStorageKeyContent {
|
||||
PassphraseInfo passphrase;
|
||||
String iv;
|
||||
String mac;
|
||||
String algorithm;
|
||||
|
||||
SecretStorageKeyContent();
|
||||
|
||||
SecretStorageKeyContent.fromJson(Map<String, dynamic> json)
|
||||
: passphrase = json['passphrase'] is Map<String, dynamic>
|
||||
? PassphraseInfo.fromJson(json['passphrase'])
|
||||
: null,
|
||||
iv = json.tryGet<String>('iv'),
|
||||
mac = json.tryGet<String>('mac'),
|
||||
algorithm = json.tryGet<String>('algorithm');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (passphrase != null) data['passphrase'] = passphrase.toJson();
|
||||
if (iv != null) data['iv'] = iv;
|
||||
if (mac != null) data['mac'] = mac;
|
||||
if (algorithm != null) data['algorithm'] = algorithm;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class PassphraseInfo {
|
||||
String algorithm;
|
||||
String salt;
|
||||
int iterations;
|
||||
int bits;
|
||||
|
||||
PassphraseInfo();
|
||||
|
||||
PassphraseInfo.fromJson(Map<String, dynamic> json)
|
||||
: algorithm = json.tryGet<String>('algorithm'),
|
||||
salt = json.tryGet<String>('salt'),
|
||||
iterations = json.tryGet<int>('iterations'),
|
||||
bits = json.tryGet<int>('bits');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (algorithm != null) data['algorithm'] = algorithm;
|
||||
if (salt != null) data['salt'] = salt;
|
||||
if (iterations != null) data['iterations'] = iterations;
|
||||
if (bits != null) data['bits'] = bits;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
import 'package:famedlysdk/matrix_api/model/basic_event.dart';
|
||||
import '../../utils/try_get_map_extension.dart';
|
||||
|
||||
extension TombstoneContentBasicEventExtension on BasicEvent {
|
||||
TombstoneContent get parsedTombstoneContent =>
|
||||
TombstoneContent.fromJson(content);
|
||||
}
|
||||
|
||||
class TombstoneContent {
|
||||
String body;
|
||||
String replacementRoom;
|
||||
|
||||
TombstoneContent.fromJson(Map<String, dynamic> json)
|
||||
: body = json.tryGet<String>('body', ''),
|
||||
replacementRoom = json.tryGet<String>('replacement_room', '');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['body'] = body;
|
||||
data['replacement_room'] = replacementRoom;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'matrix_event.dart';
|
||||
|
||||
class EventsSyncUpdate {
|
||||
String start;
|
||||
String end;
|
||||
List<MatrixEvent> chunk;
|
||||
|
||||
EventsSyncUpdate.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;
|
||||
}
|
||||
|
||||
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()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,222 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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) {
|
||||
final eventFilter = EventFilter.fromJson(json);
|
||||
limit = eventFilter.limit;
|
||||
senders = eventFilter.senders;
|
||||
types = eventFilter.types;
|
||||
notRooms = eventFilter.notRooms;
|
||||
notSenders = eventFilter.notSenders;
|
||||
|
||||
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'] = notTypes;
|
||||
}
|
||||
if (includeRedundantMembers != null) {
|
||||
data['include_redundant_members'] = notTypes;
|
||||
}
|
||||
if (containsUrl != null) {
|
||||
data['contains_url'] = notTypes;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'well_known_informations.dart';
|
||||
|
||||
class LoginResponse {
|
||||
String userId;
|
||||
String accessToken;
|
||||
String deviceId;
|
||||
WellKnownInformations wellKnownInformations;
|
||||
|
||||
LoginResponse.fromJson(Map<String, dynamic> json) {
|
||||
userId = json['user_id'];
|
||||
accessToken = json['access_token'];
|
||||
deviceId = json['device_id'];
|
||||
if (json['well_known'] is Map) {
|
||||
wellKnownInformations =
|
||||
WellKnownInformations.fromJson(json['well_known']);
|
||||
}
|
||||
}
|
||||
|
||||
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 (wellKnownInformations != null) {
|
||||
data['well_known'] = wellKnownInformations.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class LoginTypes {
|
||||
List<Flows> flows;
|
||||
|
||||
LoginTypes.fromJson(Map<String, dynamic> json) {
|
||||
if (json['flows'] != null) {
|
||||
flows = <Flows>[];
|
||||
json['flows'].forEach((v) {
|
||||
flows.add(Flows.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class MatrixConnectionException implements Exception {
|
||||
final dynamic original;
|
||||
final StackTrace stackTrace;
|
||||
MatrixConnectionException(this.original, this.stackTrace);
|
||||
|
||||
@override
|
||||
String toString() => original.toString();
|
||||
}
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'stripped_state_event.dart';
|
||||
import '../utils/map_copy_extension.dart';
|
||||
|
||||
class MatrixEvent extends StrippedStateEvent {
|
||||
String eventId;
|
||||
String roomId;
|
||||
DateTime originServerTs;
|
||||
Map<String, dynamic> unsigned;
|
||||
Map<String, dynamic> prevContent;
|
||||
String redacts;
|
||||
|
||||
MatrixEvent();
|
||||
|
||||
MatrixEvent.fromJson(Map<String, dynamic> json) {
|
||||
final strippedStateEvent = StrippedStateEvent.fromJson(json);
|
||||
content = strippedStateEvent.content;
|
||||
type = strippedStateEvent.type;
|
||||
senderId = strippedStateEvent.senderId;
|
||||
stateKey = strippedStateEvent.stateKey;
|
||||
eventId = json['event_id'];
|
||||
roomId = json['room_id'];
|
||||
originServerTs =
|
||||
DateTime.fromMillisecondsSinceEpoch(json['origin_server_ts']);
|
||||
unsigned = (json['unsigned'] as Map<String, dynamic>)?.copy();
|
||||
prevContent = (json['prev_content'] as Map<String, dynamic>)?.copy();
|
||||
redacts = json['redacts'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['event_id'] = eventId;
|
||||
data['origin_server_ts'] = originServerTs.millisecondsSinceEpoch;
|
||||
if (unsigned != null) {
|
||||
data['unsigned'] = unsigned;
|
||||
}
|
||||
if (prevContent != null) {
|
||||
data['prev_content'] = prevContent;
|
||||
}
|
||||
if (roomId != null) {
|
||||
data['room_id'] = roomId;
|
||||
}
|
||||
if (data['state_key'] == null) {
|
||||
data.remove('state_key');
|
||||
}
|
||||
if (redacts != null) {
|
||||
data['redacts'] = redacts;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
enum MatrixError {
|
||||
M_UNKNOWN,
|
||||
M_UNKNOWN_TOKEN,
|
||||
M_NOT_FOUND,
|
||||
M_FORBIDDEN,
|
||||
M_LIMIT_EXCEEDED,
|
||||
M_USER_IN_USE,
|
||||
M_THREEPID_IN_USE,
|
||||
M_THREEPID_DENIED,
|
||||
M_THREEPID_NOT_FOUND,
|
||||
M_THREEPID_AUTH_FAILED,
|
||||
M_TOO_LARGE,
|
||||
M_MISSING_PARAM,
|
||||
M_UNSUPPORTED_ROOM_VERSION,
|
||||
M_UNRECOGNIZED,
|
||||
}
|
||||
|
||||
/// Represents a special response from the Homeserver for errors.
|
||||
class MatrixException implements Exception {
|
||||
final Map<String, dynamic> raw;
|
||||
|
||||
/// The unique identifier for this error.
|
||||
String get errcode =>
|
||||
raw['errcode'] ??
|
||||
(requireAdditionalAuthentication ? 'M_FORBIDDEN' : 'M_UNKNOWN');
|
||||
|
||||
/// A human readable error description.
|
||||
String get errorMessage =>
|
||||
raw['error'] ??
|
||||
(requireAdditionalAuthentication
|
||||
? 'Require additional authentication'
|
||||
: 'Unknown error');
|
||||
|
||||
/// The frozen request which triggered this Error
|
||||
http.Response response;
|
||||
|
||||
MatrixException(this.response) : raw = json.decode(response.body);
|
||||
MatrixException.fromJson(Map<String, dynamic> content) : raw = content;
|
||||
|
||||
@override
|
||||
String toString() => '$errcode: $errorMessage';
|
||||
|
||||
/// Returns the [ResponseError]. Is ResponseError.NONE if there wasn't an error.
|
||||
MatrixError get error => MatrixError.values.firstWhere(
|
||||
(e) => e.toString() == 'MatrixError.${(raw["errcode"] ?? "")}',
|
||||
orElse: () => MatrixError.M_UNKNOWN);
|
||||
|
||||
int get retryAfterMs => raw['retry_after_ms'];
|
||||
|
||||
/// This is a session identifier that the client must pass back to the homeserver, if one is provided,
|
||||
/// in subsequent attempts to authenticate in the same API call.
|
||||
String get session => raw['session'];
|
||||
|
||||
/// Returns true if the server requires additional authentication.
|
||||
bool get requireAdditionalAuthentication => response != null
|
||||
? response.statusCode == 401
|
||||
: authenticationFlows != null;
|
||||
|
||||
/// For each endpoint, a server offers one or more 'flows' that the client can use
|
||||
/// to authenticate itself. Each flow comprises a series of stages. If this request
|
||||
/// doesn't need additional authentication, then this is null.
|
||||
List<AuthenticationFlow> get authenticationFlows {
|
||||
if (!raw.containsKey('flows') || !(raw['flows'] is List)) return null;
|
||||
var flows = <AuthenticationFlow>[];
|
||||
for (Map<String, dynamic> flow in raw['flows']) {
|
||||
if (flow['stages'] is List) {
|
||||
flows.add(AuthenticationFlow(List<String>.from(flow['stages'])));
|
||||
}
|
||||
}
|
||||
return flows;
|
||||
}
|
||||
|
||||
/// This section contains any information that the client will need to know in order to use a given type
|
||||
/// of authentication. For each authentication type presented, that type may be present as a key in this
|
||||
/// dictionary. For example, the public part of an OAuth client ID could be given here.
|
||||
Map<String, dynamic> get authenticationParams => raw['params'];
|
||||
|
||||
/// Returns the list of already completed authentication flows from previous requests.
|
||||
List<String> get completedAuthenticationFlows =>
|
||||
List<String>.from(raw['completed'] ?? []);
|
||||
}
|
||||
|
||||
/// For each endpoint, a server offers one or more 'flows' that the client can use
|
||||
/// to authenticate itself. Each flow comprises a series of stages
|
||||
class AuthenticationFlow {
|
||||
final List<String> stages;
|
||||
const AuthenticationFlow(this.stages);
|
||||
}
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import '../utils/map_copy_extension.dart';
|
||||
|
||||
class MatrixSignableKey {
|
||||
String userId;
|
||||
String identifier;
|
||||
Map<String, String> keys;
|
||||
Map<String, Map<String, String>> signatures;
|
||||
Map<String, dynamic> unsigned;
|
||||
|
||||
MatrixSignableKey(this.userId, this.identifier, this.keys, this.signatures,
|
||||
{this.unsigned});
|
||||
|
||||
// This object is used for signing so we need the raw json too
|
||||
Map<String, dynamic> _json;
|
||||
|
||||
MatrixSignableKey.fromJson(Map<String, dynamic> json) {
|
||||
_json = json;
|
||||
userId = json['user_id'];
|
||||
keys = Map<String, String>.from(json['keys']);
|
||||
// we need to manually copy to ensure that our map is Map<String, Map<String, String>>
|
||||
signatures = json['signatures'] is Map
|
||||
? Map<String, Map<String, String>>.from((json['signatures'] as Map)
|
||||
.map((k, v) => MapEntry(k, Map<String, String>.from(v))))
|
||||
: null;
|
||||
unsigned = (json['unsigned'] as Map<String, dynamic>)?.copy();
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = _json ?? <String, dynamic>{};
|
||||
data['user_id'] = userId;
|
||||
data['keys'] = keys;
|
||||
|
||||
if (signatures != null) {
|
||||
data['signatures'] = signatures;
|
||||
}
|
||||
if (unsigned != null) {
|
||||
data['unsigned'] = unsigned;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class MatrixCrossSigningKey extends MatrixSignableKey {
|
||||
List<String> usage;
|
||||
String get publicKey => identifier;
|
||||
|
||||
MatrixCrossSigningKey(
|
||||
String userId,
|
||||
this.usage,
|
||||
Map<String, String> keys,
|
||||
Map<String, Map<String, String>> signatures, {
|
||||
Map<String, dynamic> unsigned,
|
||||
}) : super(userId, keys?.values?.first, keys, signatures, unsigned: unsigned);
|
||||
|
||||
@override
|
||||
MatrixCrossSigningKey.fromJson(Map<String, dynamic> json)
|
||||
: super.fromJson(json) {
|
||||
usage = List<String>.from(json['usage']);
|
||||
identifier = keys?.values?.first;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['usage'] = usage;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class MatrixDeviceKeys extends MatrixSignableKey {
|
||||
String get deviceId => identifier;
|
||||
List<String> algorithms;
|
||||
String get deviceDisplayName =>
|
||||
unsigned != null ? unsigned['device_display_name'] : null;
|
||||
|
||||
MatrixDeviceKeys(
|
||||
String userId,
|
||||
String deviceId,
|
||||
this.algorithms,
|
||||
Map<String, String> keys,
|
||||
Map<String, Map<String, String>> signatures, {
|
||||
Map<String, dynamic> unsigned,
|
||||
}) : super(userId, deviceId, keys, signatures, unsigned: unsigned);
|
||||
|
||||
@override
|
||||
MatrixDeviceKeys.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
identifier = json['device_id'];
|
||||
algorithms = json['algorithms'].cast<String>();
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['device_id'] = deviceId;
|
||||
data['algorithms'] = algorithms;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
abstract class MessageTypes {
|
||||
static const String Text = 'm.text';
|
||||
static const String Emote = 'm.emote';
|
||||
static const String Notice = 'm.notice';
|
||||
static const String Image = 'm.image';
|
||||
static const String Video = 'm.video';
|
||||
static const String Audio = 'm.audio';
|
||||
static const String File = 'm.file';
|
||||
static const String Location = 'm.location';
|
||||
static const String Sticker = 'm.sticker';
|
||||
static const String BadEncrypted = 'm.bad.encrypted';
|
||||
static const String None = 'm.none';
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'matrix_event.dart';
|
||||
|
||||
class NotificationsQueryResponse {
|
||||
String nextToken;
|
||||
List<Notification> notifications;
|
||||
|
||||
NotificationsQueryResponse.fromJson(Map<String, dynamic> json) {
|
||||
nextToken = json['next_token'];
|
||||
notifications = <Notification>[];
|
||||
json['notifications'].forEach((v) {
|
||||
notifications.add(Notification.fromJson(v));
|
||||
});
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'basic_event_with_sender.dart';
|
||||
import 'presence_content.dart';
|
||||
|
||||
class Presence extends BasicEventWithSender {
|
||||
PresenceContent presence;
|
||||
|
||||
Presence.fromJson(Map<String, dynamic> json) {
|
||||
final basicEvent = BasicEventWithSender.fromJson(json);
|
||||
type = basicEvent.type;
|
||||
content = basicEvent.content;
|
||||
senderId = basicEvent.senderId;
|
||||
presence = PresenceContent.fromJson(content);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
enum PresenceType { online, offline, unavailable }
|
||||
|
||||
class PresenceContent {
|
||||
PresenceType presence;
|
||||
int lastActiveAgo;
|
||||
String statusMsg;
|
||||
bool currentlyActive;
|
||||
|
||||
PresenceContent.fromJson(Map<String, dynamic> json) {
|
||||
presence = PresenceType.values
|
||||
.firstWhere((p) => p.toString().split('.').last == json['presence']);
|
||||
lastActiveAgo = json['last_active_ago'];
|
||||
statusMsg = json['status_msg'];
|
||||
currentlyActive = json['currently_active'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['presence'] = presence.toString().split('.').last;
|
||||
if (lastActiveAgo != null) {
|
||||
data['last_active_ago'] = lastActiveAgo;
|
||||
}
|
||||
if (statusMsg != null) {
|
||||
data['status_msg'] = statusMsg;
|
||||
}
|
||||
if (currentlyActive != null) {
|
||||
data['currently_active'] = currentlyActive;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class PublicRoomsResponse {
|
||||
List<PublicRoom> chunk;
|
||||
String nextBatch;
|
||||
String prevBatch;
|
||||
int totalRoomCountEstimate;
|
||||
|
||||
PublicRoomsResponse.fromJson(Map<String, dynamic> json) {
|
||||
chunk = <PublicRoom>[];
|
||||
json['chunk'].forEach((v) {
|
||||
chunk.add(PublicRoom.fromJson(v));
|
||||
});
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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) {
|
||||
if (json.containsKey('url')) {
|
||||
url = Uri.parse(json['url']);
|
||||
}
|
||||
format = json['format'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (url != null) {
|
||||
data['url'] = url.toString();
|
||||
}
|
||||
if (format != null) {
|
||||
data['format'] = format;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class RequestTokenResponse {
|
||||
String sid;
|
||||
String submitUrl;
|
||||
|
||||
RequestTokenResponse.fromJson(Map<String, dynamic> json) {
|
||||
sid = json['sid'];
|
||||
submitUrl = json['submit_url'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['sid'] = sid;
|
||||
data['submit_url'] = submitUrl;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class RoomAliasInformations {
|
||||
String roomId;
|
||||
List<String> servers;
|
||||
|
||||
RoomAliasInformations.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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import '../../matrix_api.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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class RoomKeysSingleKey {
|
||||
int firstMessageIndex;
|
||||
int forwardedCount;
|
||||
bool isVerified;
|
||||
Map<String, dynamic> sessionData;
|
||||
|
||||
RoomKeysSingleKey(
|
||||
{this.firstMessageIndex,
|
||||
this.forwardedCount,
|
||||
this.isVerified,
|
||||
this.sessionData});
|
||||
|
||||
RoomKeysSingleKey.fromJson(Map<String, dynamic> json) {
|
||||
firstMessageIndex = json['first_message_index'];
|
||||
forwardedCount = json['forwarded_count'];
|
||||
isVerified = json['is_verified'];
|
||||
sessionData = json['session_data'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['first_message_index'] = firstMessageIndex;
|
||||
data['forwarded_count'] = forwardedCount;
|
||||
data['is_verified'] = isVerified;
|
||||
data['session_data'] = sessionData;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class RoomKeysRoom {
|
||||
Map<String, RoomKeysSingleKey> sessions;
|
||||
|
||||
RoomKeysRoom({this.sessions}) {
|
||||
sessions ??= <String, RoomKeysSingleKey>{};
|
||||
}
|
||||
|
||||
RoomKeysRoom.fromJson(Map<String, dynamic> json) {
|
||||
sessions = (json['sessions'] as Map)
|
||||
.map((k, v) => MapEntry(k, RoomKeysSingleKey.fromJson(v)));
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['sessions'] = sessions.map((k, v) => MapEntry(k, v.toJson()));
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
RoomKeysUpdateResponse.fromJson(Map<String, dynamic> json) {
|
||||
etag = json['etag']; // synapse replies an int but docs say string?
|
||||
count = json['count'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['etag'] = etag;
|
||||
data['count'] = count;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class RoomSummary {
|
||||
List<String> mHeroes;
|
||||
int mJoinedMemberCount;
|
||||
int mInvitedMemberCount;
|
||||
RoomSummary.fromJson(Map<String, dynamic> json) {
|
||||
mHeroes =
|
||||
json['m.heroes'] != null ? List<String>.from(json['m.heroes']) : null;
|
||||
mJoinedMemberCount = json['m.joined_member_count'];
|
||||
mInvitedMemberCount = json['m.invited_member_count'];
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (mHeroes != null) {
|
||||
data['m.heroes'] = mHeroes;
|
||||
}
|
||||
if (mJoinedMemberCount != null) {
|
||||
data['m.joined_member_count'] = mJoinedMemberCount;
|
||||
}
|
||||
if (mInvitedMemberCount != null) {
|
||||
data['m.invited_member_count'] = mInvitedMemberCount;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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();
|
||||
customCapabilities.remove('m.change_password');
|
||||
customCapabilities.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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'basic_event_with_sender.dart';
|
||||
|
||||
class StrippedStateEvent extends BasicEventWithSender {
|
||||
String stateKey;
|
||||
|
||||
StrippedStateEvent();
|
||||
StrippedStateEvent.fromJson(Map<String, dynamic> json) {
|
||||
final basicEvent = BasicEventWithSender.fromJson(json);
|
||||
content = basicEvent.content;
|
||||
type = basicEvent.type;
|
||||
senderId = basicEvent.senderId;
|
||||
stateKey = json['state_key'];
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = super.toJson();
|
||||
data['state_key'] = stateKey;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class SupportedProtocol {
|
||||
List<String> userFields;
|
||||
List<String> locationFields;
|
||||
String icon;
|
||||
Map<String, ProtocolFieldType> fieldTypes;
|
||||
List<ProtocolInstance> instances;
|
||||
|
||||
SupportedProtocol.fromJson(Map<String, dynamic> json) {
|
||||
userFields = json['user_fields'].cast<String>();
|
||||
locationFields = json['location_fields'].cast<String>();
|
||||
icon = json['icon'];
|
||||
fieldTypes = (json['field_types'] as Map)
|
||||
.map((k, v) => MapEntry(k, ProtocolFieldType.fromJson(v)));
|
||||
instances = <ProtocolInstance>[];
|
||||
json['instances'].forEach((v) {
|
||||
instances.add(ProtocolInstance.fromJson(v));
|
||||
});
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['user_fields'] = userFields;
|
||||
data['location_fields'] = locationFields;
|
||||
data['icon'] = icon;
|
||||
data['field_types'] = fieldTypes.map((k, v) => MapEntry(k, v.toJson()));
|
||||
|
||||
data['instances'] = instances.map((v) => v.toJson()).toList();
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class ProtocolFieldType {
|
||||
String regexp;
|
||||
String placeholder;
|
||||
|
||||
ProtocolFieldType.fromJson(Map<String, dynamic> json) {
|
||||
regexp = json['regexp'];
|
||||
placeholder = json['placeholder'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['regexp'] = regexp;
|
||||
data['placeholder'] = placeholder;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class ProtocolInstance {
|
||||
String networkId;
|
||||
String desc;
|
||||
String icon;
|
||||
dynamic fields;
|
||||
|
||||
ProtocolInstance.fromJson(Map<String, dynamic> json) {
|
||||
networkId = json['network_id'];
|
||||
desc = json['desc'];
|
||||
icon = json['icon'];
|
||||
fields = json['fields'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['network_id'] = networkId;
|
||||
data['desc'] = desc;
|
||||
if (icon != null) {
|
||||
data['icon'] = icon;
|
||||
}
|
||||
data['fields'] = fields;
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,333 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'basic_event.dart';
|
||||
import 'basic_event_with_sender.dart';
|
||||
import 'basic_room_event.dart';
|
||||
import 'matrix_event.dart';
|
||||
import 'presence.dart';
|
||||
import 'room_summary.dart';
|
||||
import 'stripped_state_event.dart';
|
||||
|
||||
class SyncUpdate {
|
||||
String nextBatch;
|
||||
RoomsUpdate rooms;
|
||||
List<Presence> presence;
|
||||
List<BasicEvent> accountData;
|
||||
List<BasicEventWithSender> toDevice;
|
||||
DeviceListsUpdate deviceLists;
|
||||
Map<String, int> deviceOneTimeKeysCount;
|
||||
|
||||
SyncUpdate();
|
||||
|
||||
SyncUpdate.fromJson(Map<String, dynamic> json) {
|
||||
nextBatch = json['next_batch'];
|
||||
rooms = json['rooms'] != null ? RoomsUpdate.fromJson(json['rooms']) : null;
|
||||
presence = (json['presence'] != null && json['presence']['events'] != null)
|
||||
? (json['presence']['events'] as List)
|
||||
.map((i) => Presence.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
accountData =
|
||||
(json['account_data'] != null && json['account_data']['events'] != null)
|
||||
? (json['account_data']['events'] as List)
|
||||
.map((i) => BasicEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
toDevice =
|
||||
(json['to_device'] != null && json['to_device']['events'] != null)
|
||||
? (json['to_device']['events'] as List)
|
||||
.map((i) => BasicEventWithSender.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
deviceLists = json['device_lists'] != null
|
||||
? DeviceListsUpdate.fromJson(json['device_lists'])
|
||||
: null;
|
||||
deviceOneTimeKeysCount = json['device_one_time_keys_count'] != null
|
||||
? Map<String, int>.from(json['device_one_time_keys_count'])
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['next_batch'] = nextBatch;
|
||||
if (rooms != null) {
|
||||
data['rooms'] = rooms.toJson();
|
||||
}
|
||||
if (presence != null) {
|
||||
data['presence'] = {
|
||||
'events': presence.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (accountData != null) {
|
||||
data['account_data'] = {
|
||||
'events': accountData.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (toDevice != null) {
|
||||
data['to_device'] = {
|
||||
'events': toDevice.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (deviceLists != null) {
|
||||
data['device_lists'] = deviceLists.toJson();
|
||||
}
|
||||
if (deviceOneTimeKeysCount != null) {
|
||||
data['device_one_time_keys_count'] = deviceOneTimeKeysCount;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class RoomsUpdate {
|
||||
Map<String, JoinedRoomUpdate> join;
|
||||
Map<String, InvitedRoomUpdate> invite;
|
||||
Map<String, LeftRoomUpdate> leave;
|
||||
|
||||
RoomsUpdate();
|
||||
|
||||
RoomsUpdate.fromJson(Map<String, dynamic> json) {
|
||||
join = json['join'] != null
|
||||
? (json['join'] as Map)
|
||||
.map((k, v) => MapEntry(k, JoinedRoomUpdate.fromJson(v)))
|
||||
: null;
|
||||
invite = json['invite'] != null
|
||||
? (json['invite'] as Map)
|
||||
.map((k, v) => MapEntry(k, InvitedRoomUpdate.fromJson(v)))
|
||||
: null;
|
||||
leave = json['leave'] != null
|
||||
? (json['leave'] as Map)
|
||||
.map((k, v) => MapEntry(k, LeftRoomUpdate.fromJson(v)))
|
||||
: null;
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (join != null) {
|
||||
data['join'] = join.map((k, v) => MapEntry(k, v.toJson()));
|
||||
}
|
||||
if (invite != null) {
|
||||
data['invite'] = invite.map((k, v) => MapEntry(k, v.toJson()));
|
||||
}
|
||||
if (leave != null) {
|
||||
data['leave'] = leave.map((k, v) => MapEntry(k, v.toJson()));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SyncRoomUpdate {}
|
||||
|
||||
class JoinedRoomUpdate extends SyncRoomUpdate {
|
||||
RoomSummary summary;
|
||||
List<MatrixEvent> state;
|
||||
TimelineUpdate timeline;
|
||||
List<BasicRoomEvent> ephemeral;
|
||||
List<BasicRoomEvent> accountData;
|
||||
UnreadNotificationCounts unreadNotifications;
|
||||
|
||||
JoinedRoomUpdate();
|
||||
|
||||
JoinedRoomUpdate.fromJson(Map<String, dynamic> json) {
|
||||
summary =
|
||||
json['summary'] != null ? RoomSummary.fromJson(json['summary']) : null;
|
||||
state = (json['state'] != null && json['state']['events'] != null)
|
||||
? (json['state']['events'] as List)
|
||||
.map((i) => MatrixEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
timeline = json['timeline'] != null
|
||||
? TimelineUpdate.fromJson(json['timeline'])
|
||||
: null;
|
||||
|
||||
ephemeral =
|
||||
(json['ephemeral'] != null && json['ephemeral']['events'] != null)
|
||||
? (json['ephemeral']['events'] as List)
|
||||
.map((i) => BasicRoomEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
accountData =
|
||||
(json['account_data'] != null && json['account_data']['events'] != null)
|
||||
? (json['account_data']['events'] as List)
|
||||
.map((i) => BasicRoomEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
unreadNotifications = json['unread_notifications'] != null
|
||||
? UnreadNotificationCounts.fromJson(json['unread_notifications'])
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (summary != null) {
|
||||
data['summary'] = summary.toJson();
|
||||
}
|
||||
if (state != null) {
|
||||
data['state'] = {
|
||||
'events': state.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (timeline != null) {
|
||||
data['timeline'] = timeline.toJson();
|
||||
}
|
||||
if (ephemeral != null) {
|
||||
data['ephemeral'] = {
|
||||
'events': ephemeral.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (accountData != null) {
|
||||
data['account_data'] = {
|
||||
'events': accountData.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (unreadNotifications != null) {
|
||||
data['unread_notifications'] = unreadNotifications.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class InvitedRoomUpdate extends SyncRoomUpdate {
|
||||
List<StrippedStateEvent> inviteState;
|
||||
InvitedRoomUpdate.fromJson(Map<String, dynamic> json) {
|
||||
inviteState =
|
||||
(json['invite_state'] != null && json['invite_state']['events'] != null)
|
||||
? (json['invite_state']['events'] as List)
|
||||
.map((i) => StrippedStateEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (inviteState != null) {
|
||||
data['invite_state'] = {
|
||||
'events': inviteState.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class LeftRoomUpdate extends SyncRoomUpdate {
|
||||
List<MatrixEvent> state;
|
||||
TimelineUpdate timeline;
|
||||
List<BasicRoomEvent> accountData;
|
||||
|
||||
LeftRoomUpdate();
|
||||
|
||||
LeftRoomUpdate.fromJson(Map<String, dynamic> json) {
|
||||
state = (json['state'] != null && json['state']['events'] != null)
|
||||
? (json['state']['events'] as List)
|
||||
.map((i) => MatrixEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
timeline = json['timeline'] != null
|
||||
? TimelineUpdate.fromJson(json['timeline'])
|
||||
: null;
|
||||
accountData =
|
||||
(json['account_data'] != null && json['account_data']['events'] != null)
|
||||
? (json['account_data']['events'] as List)
|
||||
.map((i) => BasicRoomEvent.fromJson(i))
|
||||
.toList()
|
||||
: null;
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (state != null) {
|
||||
data['state'] = {
|
||||
'events': state.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (timeline != null) {
|
||||
data['timeline'] = timeline.toJson();
|
||||
}
|
||||
if (accountData != null) {
|
||||
data['account_data'] = {
|
||||
'events': accountData.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class TimelineUpdate {
|
||||
List<MatrixEvent> events;
|
||||
bool limited;
|
||||
String prevBatch;
|
||||
|
||||
TimelineUpdate();
|
||||
|
||||
TimelineUpdate.fromJson(Map<String, dynamic> json) {
|
||||
events = json['events'] != null
|
||||
? (json['events'] as List).map((i) => MatrixEvent.fromJson(i)).toList()
|
||||
: null;
|
||||
limited = json['limited'];
|
||||
prevBatch = json['prev_batch'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (events != null) {
|
||||
data['events'] = events.map((i) => i.toJson()).toList();
|
||||
}
|
||||
if (limited != null) {
|
||||
data['limited'] = limited;
|
||||
}
|
||||
if (prevBatch != null) {
|
||||
data['prev_batch'] = prevBatch;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class UnreadNotificationCounts {
|
||||
int highlightCount;
|
||||
int notificationCount;
|
||||
UnreadNotificationCounts.fromJson(Map<String, dynamic> json) {
|
||||
highlightCount = json['highlight_count'];
|
||||
notificationCount = json['notification_count'];
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (highlightCount != null) {
|
||||
data['highlight_count'] = highlightCount;
|
||||
}
|
||||
if (notificationCount != null) {
|
||||
data['notification_count'] = notificationCount;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class DeviceListsUpdate {
|
||||
List<String> changed;
|
||||
List<String> left;
|
||||
DeviceListsUpdate.fromJson(Map<String, dynamic> json) {
|
||||
changed = List<String>.from(json['changed'] ?? []);
|
||||
left = List<String>.from(json['left'] ?? []);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (changed != null) {
|
||||
data['changed'] = changed;
|
||||
}
|
||||
if (left != null) {
|
||||
data['left'] = left;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:famedlysdk/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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import '../utils/map_copy_extension.dart';
|
||||
|
||||
class ThirdPartyLocation {
|
||||
String alias;
|
||||
String protocol;
|
||||
Map<String, dynamic> fields;
|
||||
|
||||
ThirdPartyLocation.fromJson(Map<String, dynamic> json) {
|
||||
alias = json['alias'];
|
||||
protocol = json['protocol'];
|
||||
fields = (json['fields'] as Map<String, dynamic>).copy();
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['alias'] = alias;
|
||||
data['protocol'] = protocol;
|
||||
data['fields'] = fields;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import '../utils/map_copy_extension.dart';
|
||||
|
||||
class ThirdPartyUser {
|
||||
String userId;
|
||||
String protocol;
|
||||
Map<String, dynamic> fields;
|
||||
|
||||
ThirdPartyUser.fromJson(Map<String, dynamic> json) {
|
||||
userId = json['userid'];
|
||||
protocol = json['protocol'];
|
||||
fields = (json['fields'] as Map<String, dynamic>).copy();
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['userid'] = userId;
|
||||
data['protocol'] = protocol;
|
||||
data['fields'] = fields;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'matrix_exception.dart';
|
||||
|
||||
class UploadKeySignaturesResponse {
|
||||
Map<String, Map<String, MatrixException>> failures;
|
||||
|
||||
UploadKeySignaturesResponse.fromJson(Map<String, dynamic> 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<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (failures != null) {
|
||||
data['failures'] = failures.map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
v.map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
v.raw,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'profile.dart';
|
||||
|
||||
class UserSearchResult {
|
||||
List<Profile> results;
|
||||
bool limited;
|
||||
|
||||
UserSearchResult.fromJson(Map<String, dynamic> json) {
|
||||
results = <Profile>[];
|
||||
json['results'].forEach((v) {
|
||||
results.add(Profile.fromJson(v));
|
||||
});
|
||||
|
||||
limited = json['limited'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['results'] = results.map((v) => v.toJson()).toList();
|
||||
|
||||
data['limited'] = limited;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class WellKnownInformations {
|
||||
MHomeserver mHomeserver;
|
||||
MHomeserver mIdentityServer;
|
||||
Map<String, dynamic> content;
|
||||
|
||||
WellKnownInformations.fromJson(Map<String, dynamic> json) {
|
||||
content = json;
|
||||
mHomeserver = json['m.homeserver'] != null
|
||||
? MHomeserver.fromJson(json['m.homeserver'])
|
||||
: null;
|
||||
mIdentityServer = json['m.identity_server'] != null
|
||||
? MHomeserver.fromJson(json['m.identity_server'])
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = content;
|
||||
data['m.homeserver'] = mHomeserver.toJson();
|
||||
data['m.identity_server'] = mIdentityServer.toJson();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class MHomeserver {
|
||||
String baseUrl;
|
||||
|
||||
MHomeserver.fromJson(Map<String, dynamic> json) {
|
||||
baseUrl = json['base_url'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['base_url'] = baseUrl;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 = <Sessions>[];
|
||||
json['sessions'].forEach((v) {
|
||||
sessions.add(Sessions.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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 = <Connections>[];
|
||||
json['connections'].forEach((v) {
|
||||
connections.add(Connections.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2020 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:logger/logger.dart';
|
||||
|
||||
class Logs extends Logger {
|
||||
static final Logs _singleton = Logs._internal();
|
||||
|
||||
factory Logs() {
|
||||
return _singleton;
|
||||
}
|
||||
|
||||
set level(Level newLevel) => Logger.level = newLevel;
|
||||
|
||||
final List<OutputEvent> outputEvents = [];
|
||||
|
||||
Logs._internal()
|
||||
: super(
|
||||
printer: PrettyPrinter(methodCount: 0, lineLength: 100),
|
||||
filter: _MatrixSdkFilter(),
|
||||
output: _CacheOutput(),
|
||||
);
|
||||
}
|
||||
|
||||
class _MatrixSdkFilter extends LogFilter {
|
||||
@override
|
||||
bool shouldLog(LogEvent event) => event.level.index >= Logger.level.index;
|
||||
}
|
||||
|
||||
class _CacheOutput extends ConsoleOutput {
|
||||
@override
|
||||
void output(OutputEvent event) {
|
||||
Logs().outputEvents.add(event);
|
||||
super.output(event);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
import 'logs.dart';
|
||||
|
||||
extension TryGetMapExtension on Map<String, dynamic> {
|
||||
T tryGet<T>(String key, [T fallbackValue]) {
|
||||
final value = this[key];
|
||||
if (value != null && !(value is T)) {
|
||||
Logs().w(
|
||||
'Expected "${T.runtimeType}" in event content for the Key "$key" but got "${value.runtimeType}".');
|
||||
return fallbackValue;
|
||||
}
|
||||
if (value == null && fallbackValue != null) {
|
||||
Logs().w(
|
||||
'Required field in event content for the Key "$key" is null. Set to "$fallbackValue".');
|
||||
return fallbackValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -26,7 +26,6 @@ import 'package:pedantic/pedantic.dart';
|
|||
|
||||
import '../encryption.dart';
|
||||
import '../famedlysdk.dart';
|
||||
import '../matrix_api/utils/logs.dart';
|
||||
import 'database/database.dart' show Database;
|
||||
import 'event.dart';
|
||||
import 'room.dart';
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ import 'dart:convert';
|
|||
import 'package:moor/moor.dart';
|
||||
|
||||
import '../../famedlysdk.dart' as sdk;
|
||||
import '../../matrix_api.dart' as api;
|
||||
import '../../matrix_api/utils/logs.dart';
|
||||
import 'package:matrix_api_lite/matrix_api_lite.dart' as api;
|
||||
import '../client.dart';
|
||||
import '../room.dart';
|
||||
|
||||
|
|
@ -66,7 +65,7 @@ class Database extends _$Database {
|
|||
try {
|
||||
await m.createAll();
|
||||
} catch (e, s) {
|
||||
Logs().e('Create all failed in database migrator', e, s);
|
||||
api.Logs().e('Create all failed in database migrator', e, s);
|
||||
onError.add(SdkError(exception: e, stackTrace: s));
|
||||
rethrow;
|
||||
}
|
||||
|
|
@ -148,7 +147,7 @@ class Database extends _$Database {
|
|||
from++;
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logs().e('Database migration failed', e, s);
|
||||
api.Logs().e('Database migration failed', e, s);
|
||||
onError.add(SdkError(exception: e, stackTrace: s));
|
||||
rethrow;
|
||||
}
|
||||
|
|
@ -158,12 +157,12 @@ class Database extends _$Database {
|
|||
if (executor.dialect == SqlDialect.sqlite) {
|
||||
final ret = await customSelect('PRAGMA journal_mode=WAL').get();
|
||||
if (ret.isNotEmpty) {
|
||||
Logs().v('[Moor] Switched database to mode ' +
|
||||
api.Logs().v('[Moor] Switched database to mode ' +
|
||||
ret.first.data['journal_mode'].toString());
|
||||
}
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logs().e('Database before open failed', e, s);
|
||||
api.Logs().e('Database before open failed', e, s);
|
||||
onError.add(SdkError(exception: e, stackTrace: s));
|
||||
rethrow;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import 'package:http/http.dart' as http;
|
|||
import 'package:matrix_file_e2ee/matrix_file_e2ee.dart';
|
||||
|
||||
import '../famedlysdk.dart';
|
||||
import '../matrix_api.dart';
|
||||
import 'database/database.dart' show DbRoomState, DbEvent;
|
||||
import 'room.dart';
|
||||
import 'utils/matrix_localizations.dart';
|
||||
|
|
|
|||
|
|
@ -18,21 +18,18 @@
|
|||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:famedlysdk/matrix_api/model/marked_unread.dart';
|
||||
import 'package:html_unescape/html_unescape.dart';
|
||||
import 'package:matrix_file_e2ee/matrix_file_e2ee.dart';
|
||||
|
||||
import '../famedlysdk.dart';
|
||||
import '../matrix_api.dart';
|
||||
import 'client.dart';
|
||||
import 'database/database.dart' show DbRoom;
|
||||
import 'event.dart';
|
||||
import 'timeline.dart';
|
||||
import 'user.dart';
|
||||
import 'utils/event_update.dart';
|
||||
import '../matrix_api/utils/logs.dart';
|
||||
import '../matrix_api/utils/try_get_map_extension.dart';
|
||||
import 'utils/markdown.dart';
|
||||
import 'utils/marked_unread.dart';
|
||||
import 'utils/matrix_file.dart';
|
||||
import 'utils/matrix_localizations.dart';
|
||||
import 'utils/states_map.dart';
|
||||
|
|
|
|||
|
|
@ -18,11 +18,10 @@
|
|||
|
||||
import 'dart:async';
|
||||
|
||||
import '../matrix_api.dart';
|
||||
import '../famedlysdk.dart';
|
||||
import 'event.dart';
|
||||
import 'room.dart';
|
||||
import 'utils/event_update.dart';
|
||||
import '../matrix_api/utils/logs.dart';
|
||||
import 'utils/room_update.dart';
|
||||
|
||||
typedef onTimelineUpdateCallback = void Function();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
import '../famedlysdk.dart';
|
||||
import '../matrix_api.dart';
|
||||
|
||||
import 'event.dart';
|
||||
import 'room.dart';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:canonical_json/canonical_json.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
|
||||
import '../../encryption.dart';
|
||||
import '../../matrix_api.dart';
|
||||
|
||||
import '../client.dart';
|
||||
import '../database/database.dart'
|
||||
show DbUserDeviceKey, DbUserDeviceKeysKey, DbUserCrossSigningKey;
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import '../../matrix_api.dart';
|
||||
import '../../encryption.dart';
|
||||
import '../../famedlysdk.dart';
|
||||
import '../event.dart';
|
||||
import '../room.dart';
|
||||
import 'matrix_localizations.dart';
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
*/
|
||||
|
||||
import '../../famedlysdk.dart';
|
||||
import '../../matrix_api.dart';
|
||||
import '../../matrix_api/utils/logs.dart';
|
||||
|
||||
enum EventUpdateType {
|
||||
timeline,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Famedly Matrix SDK
|
||||
* Copyright (C) 2019, 2020 Famedly GmbH
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
|
@ -5,7 +5,7 @@ import 'dart:typed_data';
|
|||
import 'package:matrix_file_e2ee/matrix_file_e2ee.dart';
|
||||
import 'package:mime/mime.dart';
|
||||
|
||||
import '../../matrix_api/model/message_types.dart';
|
||||
import '../../famedlysdk.dart';
|
||||
|
||||
class MatrixFile {
|
||||
Uint8List bytes;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import '../../matrix_api.dart';
|
||||
import '../../famedlysdk.dart';
|
||||
|
||||
/// Represents a new room or an update for an
|
||||
/// already known room.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import 'dart:async';
|
||||
|
||||
import '../../matrix_api/utils/logs.dart';
|
||||
import '../../famedlysdk.dart';
|
||||
|
||||
Future<T> runInRoot<T>(FutureOr<T> Function() fn) async {
|
||||
return await Zone.root.run(() async {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import '../../famedlysdk.dart';
|
||||
import '../../matrix_api.dart';
|
||||
|
||||
/// Matrix room states are addressed by a tuple of the [type] and an
|
||||
/// optional [stateKey].
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import '../../matrix_api.dart';
|
||||
import '../../famedlysdk.dart';
|
||||
|
||||
/// This extension adds easy-to-use filters for the sync update, meant to be used on the `client.onSync` stream, e.g.
|
||||
/// `client.onSync.stream.where((s) => s.hasRoomUpdate)`. Multiple filters can easily be
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import '../../matrix_api.dart';
|
||||
import '../../famedlysdk.dart';
|
||||
|
||||
class ToDeviceEvent extends BasicEventWithSender {
|
||||
Map<String, dynamic> encryptedContent;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ dependencies:
|
|||
matrix_file_e2ee: ^1.0.5
|
||||
isolate: ^2.0.3
|
||||
logger: ^0.9.4
|
||||
matrix_api_lite:
|
||||
git:
|
||||
url: https://gitlab.com/famedly/libraries/matrix_api_lite.git
|
||||
|
||||
dev_dependencies:
|
||||
test: ^1.15.7
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
import 'package:canonical_json/canonical_json.dart';
|
||||
import 'package:famedlysdk/matrix_api/utils/logs.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ import 'dart:convert';
|
|||
import 'dart:typed_data';
|
||||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:famedlysdk/matrix_api.dart';
|
||||
import 'package:famedlysdk/matrix_api/utils/logs.dart';
|
||||
|
||||
import 'package:famedlysdk/src/client.dart';
|
||||
import 'package:famedlysdk/src/utils/event_update.dart';
|
||||
import 'package:famedlysdk/src/utils/matrix_file.dart';
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:famedlysdk/matrix_api/utils/logs.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import 'dart:convert';
|
|||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:famedlysdk/encryption.dart';
|
||||
import 'package:famedlysdk/matrix_api/utils/logs.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:famedlysdk/matrix_api/utils/logs.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:famedlysdk/matrix_api/utils/logs.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:famedlysdk/matrix_api/utils/logs.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:olm/olm.dart' as olm;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue