fluffychat/lib/utils/matrix_sdk_extensions.dart/fluffy_client.dart

41 lines
1.4 KiB
Dart
Raw Normal View History

import 'package:matrix/matrix.dart';
import 'package:matrix/encryption.dart';
2021-06-11 11:40:38 +02:00
import 'package:fluffychat/utils/database/flutter_famedly_sdk_hive_database.dart';
2021-04-12 18:33:43 +02:00
import 'package:matrix_api_lite/fake_matrix_api.dart';
import '../platform_infos.dart';
import '../famedlysdk_store.dart';
2021-02-07 17:18:38 +01:00
class FluffyClient extends Client {
2021-04-12 18:33:43 +02:00
static FluffyClient _instance;
2021-02-07 17:18:38 +01:00
2021-04-12 18:33:43 +02:00
factory FluffyClient({testMode = false}) {
2021-06-18 09:24:38 +02:00
Logs().level = Level.verbose;
2021-04-12 18:33:43 +02:00
_instance ??= FluffyClient._internal(testMode: testMode);
2021-02-07 17:18:38 +01:00
return _instance;
}
2021-04-12 18:33:43 +02:00
FluffyClient._internal({testMode = false})
2021-02-07 17:18:38 +01:00
: super(
2021-04-12 18:33:43 +02:00
testMode ? 'FluffyChat Widget Tests' : PlatformInfos.clientName,
httpClient: testMode ? FakeMatrixApi() : null,
2021-02-07 17:18:38 +01:00
enableE2eeRecovery: true,
verificationMethods: {
KeyVerificationMethod.numbers,
if (PlatformInfos.isMobile || PlatformInfos.isLinux)
KeyVerificationMethod.emoji,
},
importantStateEvents: <String>{
'im.ponies.room_emotes', // we want emotes to work properly
},
2021-06-11 11:40:38 +02:00
databaseBuilder: testMode
? null
: FlutterFamedlySdkHiveDatabase.hiveDatabaseBuilder,
legacyDatabaseBuilder: testMode ? null : getDatabase,
2021-02-07 17:18:38 +01:00
supportedLoginTypes: {
AuthenticationTypes.password,
2021-02-24 09:49:12 +01:00
if (PlatformInfos.isMobile || PlatformInfos.isWeb)
AuthenticationTypes.sso
2021-02-07 17:18:38 +01:00
},
);
}