Disable Realbooru while API is offline

This commit is contained in:
2026-05-25 14:55:42 +03:00
parent ea39cf8567
commit 3bf7fe6305
8 changed files with 29 additions and 9 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
#define MyAppName "RuleGel"
#define MyAppVersion "1.0.1"
#define MyAppVersion "1.0.2"
#define MyAppPublisher "RarDog"
#define MyAppExeName "gel_rule_app.exe"
+2 -2
View File
@@ -1,2 +1,2 @@
const appDisplayVersion = '1.0.1';
const appBuildNumber = 9;
const appDisplayVersion = '1.0.2';
const appBuildNumber = 10;
+9
View File
@@ -1,4 +1,13 @@
const ruleGelChangelog = [
RuleGelChange(
version: '1.0.2',
title: 'Realbooru safety fix',
bullets: [
'Realbooru stays available in Providers, but is disabled by default while its public DAPI is offline.',
'Provider diagnostics now surface the Realbooru API reason instead of a generic exception.',
'Existing enabled Realbooru configs are disabled on startup so the main feed is not polluted by a known-offline API.',
],
),
RuleGelChange(
version: '1.0.1',
title: 'Realbooru and mobile polish',
@@ -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);
}
}
});
+1 -1
View File
@@ -1,7 +1,7 @@
name: gel_rule_app
description: Local backend/core layer for a Flutter booru browser app.
publish_to: "none"
version: 1.0.1+9
version: 1.0.2+10
environment:
sdk: ">=3.3.0 <4.0.0"
+4
View File
@@ -74,6 +74,10 @@ void main() {
'e926',
'realbooru',
]);
expect(
providers.singleWhere((provider) => provider.id == 'realbooru').enabled,
isFalse,
);
});
test('settings saveEnabledProviders updates provider configs', () async {
+1 -1
View File
@@ -210,7 +210,7 @@ void main() {
.where((provider) => provider.id == 'realbooru')
.single;
expect(realbooru.enabled, isTrue);
expect(realbooru.enabled, isFalse);
expect(realbooru.apiType, 'realbooru');
expect(realbooru.baseUrl, 'https://realbooru.com');
});