2021-02-07 17:18:38 +01:00
|
|
|
import 'package:famedlysdk/famedlysdk.dart';
|
|
|
|
import 'package:famedlysdk/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';
|
2021-05-22 09:24:39 +02:00
|
|
|
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
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|