dart format

This commit is contained in:
2026-05-08 20:12:40 +02:00
parent 9e139b5704
commit 3b8da1d3d6
295 changed files with 6404 additions and 4161 deletions
+13 -4
View File
@@ -34,11 +34,16 @@ class AccountData {
return _password!;
}
String getUserSecret() =>
sha512.convert(utf8.encode('${getUsername()}:${getPassword()}')).toString();
String getUserSecret() => sha512
.convert(utf8.encode('${getUsername()}:${getPassword()}'))
.toString();
Future<String> getDeviceId() async => sha512
.convert(utf8.encode('${getUserSecret()}@${await FirebaseMessaging.instance.getToken()}'))
.convert(
utf8.encode(
'${getUserSecret()}@${await FirebaseMessaging.instance.getToken()}',
),
)
.toString();
Future<void> setData(String username, String password) async {
@@ -92,7 +97,11 @@ class AccountData {
/// Prefer this over embedding credentials in URLs — error logs and crash
/// reports often capture the URL but not headers.
String getBasicAuthHeader() {
if (!isPopulated()) throw Exception('AccountData (e.g. username or password) is not initialized!');
if (!isPopulated()) {
throw Exception(
'AccountData (e.g. username or password) is not initialized!',
);
}
return 'Basic ${base64Encode(utf8.encode('$_username:$_password'))}';
}
+13 -4
View File
@@ -4,11 +4,20 @@ import '../api/request_cache.dart';
class DataCleaner {
static Future<void> cleanOldCache() async {
final cacheData = await Localstore.instance.collection(RequestCache.collection).get();
final cacheData = await Localstore.instance
.collection(RequestCache.collection)
.get();
cacheData?.forEach((key, value) async {
final lastUpdate = DateTime.fromMillisecondsSinceEpoch(value['lastupdate'] as int);
if (DateTime.now().subtract(const Duration(days: 200)).isAfter(lastUpdate)) {
await Localstore.instance.collection(RequestCache.collection).doc(key.split('/').last).delete();
final lastUpdate = DateTime.fromMillisecondsSinceEpoch(
value['lastupdate'] as int,
);
if (DateTime.now()
.subtract(const Duration(days: 200))
.isAfter(lastUpdate)) {
await Localstore.instance
.collection(RequestCache.collection)
.doc(key.split('/').last)
.delete();
}
});
}
+14 -24
View File
@@ -1,10 +1,6 @@
import 'account_data.dart';
enum EndpointMode {
live,
stage,
}
enum EndpointMode { live, stage }
class EndpointOptions {
Endpoint live;
@@ -12,7 +8,7 @@ class EndpointOptions {
EndpointOptions({required this.live, required this.staged});
Endpoint get(EndpointMode mode) {
if(staged == null || mode == EndpointMode.live) return live;
if (staged == null || mode == EndpointMode.live) return live;
return staged!;
}
}
@@ -36,27 +32,21 @@ class EndpointData {
EndpointMode getEndpointMode() {
late String existingName;
existingName = AccountData().getUsername();
return existingName.startsWith('google') ? EndpointMode.stage : EndpointMode.live;
return existingName.startsWith('google')
? EndpointMode.stage
: EndpointMode.live;
}
Endpoint webuntis() => EndpointOptions(
live: Endpoint(
domain: 'marianum-fulda.webuntis.com',
),
staged: Endpoint(
domain: 'mhsl.eu',
path: '/marianum/marianummobile/webuntis/public/index.php/api'
),
).get(getEndpointMode());
live: Endpoint(domain: 'marianum-fulda.webuntis.com'),
staged: Endpoint(
domain: 'mhsl.eu',
path: '/marianum/marianummobile/webuntis/public/index.php/api',
),
).get(getEndpointMode());
Endpoint nextcloud() => EndpointOptions(
live: Endpoint(
domain: 'cloud.marianum-fulda.de',
),
staged: Endpoint(
domain: 'mhsl.eu',
path: '/marianum/marianummobile/cloud',
)
).get(getEndpointMode());
live: Endpoint(domain: 'cloud.marianum-fulda.de'),
staged: Endpoint(domain: 'mhsl.eu', path: '/marianum/marianummobile/cloud'),
).get(getEndpointMode());
}