Disable Realbooru while API is offline
This commit is contained in:
@@ -107,14 +107,17 @@ class RealbooruProvider extends GelbooruProvider {
|
||||
final success = data['success']?.toString().toLowerCase();
|
||||
if (success == 'false') {
|
||||
throw ProviderUnavailableException(
|
||||
(data['message'] ?? 'Realbooru search is unavailable').toString(),
|
||||
(data['message'] ??
|
||||
data['reason'] ??
|
||||
'Realbooru search is unavailable')
|
||||
.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
final text = data?.toString().toLowerCase() ?? '';
|
||||
if (text.contains('success="false"') || text.contains("success='false'")) {
|
||||
final message =
|
||||
RegExp(r'''message\s*=\s*["']([^"']+)["']''').firstMatch(text);
|
||||
final message = RegExp(r'''(?:message|reason)\s*=\s*["']([^"']+)["']''')
|
||||
.firstMatch(data?.toString() ?? '');
|
||||
throw ProviderUnavailableException(
|
||||
message?.group(1) ?? 'Realbooru search is unavailable',
|
||||
);
|
||||
|
||||
@@ -112,7 +112,7 @@ class ProviderRepository {
|
||||
name: 'Realbooru',
|
||||
baseUrl: 'https://realbooru.com',
|
||||
apiType: 'realbooru',
|
||||
enabled: true,
|
||||
enabled: false,
|
||||
priority: 7,
|
||||
timeoutSeconds: 20,
|
||||
customHeaders: const {},
|
||||
@@ -141,6 +141,10 @@ class ProviderRepository {
|
||||
if (exists == null) {
|
||||
await isar.providerConfigEntitys
|
||||
.put(ProviderConfigEntity.fromModel(seed));
|
||||
} else if (seed.id == 'realbooru' && exists.enabled) {
|
||||
exists.enabled = false;
|
||||
exists.updatedAt = DateTime.now();
|
||||
await isar.providerConfigEntitys.put(exists);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user