Disable Realbooru while API is offline
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#define MyAppName "RuleGel"
|
#define MyAppName "RuleGel"
|
||||||
#define MyAppVersion "1.0.1"
|
#define MyAppVersion "1.0.2"
|
||||||
#define MyAppPublisher "RarDog"
|
#define MyAppPublisher "RarDog"
|
||||||
#define MyAppExeName "gel_rule_app.exe"
|
#define MyAppExeName "gel_rule_app.exe"
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
const appDisplayVersion = '1.0.1';
|
const appDisplayVersion = '1.0.2';
|
||||||
const appBuildNumber = 9;
|
const appBuildNumber = 10;
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
const ruleGelChangelog = [
|
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(
|
RuleGelChange(
|
||||||
version: '1.0.1',
|
version: '1.0.1',
|
||||||
title: 'Realbooru and mobile polish',
|
title: 'Realbooru and mobile polish',
|
||||||
|
|||||||
@@ -107,14 +107,17 @@ class RealbooruProvider extends GelbooruProvider {
|
|||||||
final success = data['success']?.toString().toLowerCase();
|
final success = data['success']?.toString().toLowerCase();
|
||||||
if (success == 'false') {
|
if (success == 'false') {
|
||||||
throw ProviderUnavailableException(
|
throw ProviderUnavailableException(
|
||||||
(data['message'] ?? 'Realbooru search is unavailable').toString(),
|
(data['message'] ??
|
||||||
|
data['reason'] ??
|
||||||
|
'Realbooru search is unavailable')
|
||||||
|
.toString(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final text = data?.toString().toLowerCase() ?? '';
|
final text = data?.toString().toLowerCase() ?? '';
|
||||||
if (text.contains('success="false"') || text.contains("success='false'")) {
|
if (text.contains('success="false"') || text.contains("success='false'")) {
|
||||||
final message =
|
final message = RegExp(r'''(?:message|reason)\s*=\s*["']([^"']+)["']''')
|
||||||
RegExp(r'''message\s*=\s*["']([^"']+)["']''').firstMatch(text);
|
.firstMatch(data?.toString() ?? '');
|
||||||
throw ProviderUnavailableException(
|
throw ProviderUnavailableException(
|
||||||
message?.group(1) ?? 'Realbooru search is unavailable',
|
message?.group(1) ?? 'Realbooru search is unavailable',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class ProviderRepository {
|
|||||||
name: 'Realbooru',
|
name: 'Realbooru',
|
||||||
baseUrl: 'https://realbooru.com',
|
baseUrl: 'https://realbooru.com',
|
||||||
apiType: 'realbooru',
|
apiType: 'realbooru',
|
||||||
enabled: true,
|
enabled: false,
|
||||||
priority: 7,
|
priority: 7,
|
||||||
timeoutSeconds: 20,
|
timeoutSeconds: 20,
|
||||||
customHeaders: const {},
|
customHeaders: const {},
|
||||||
@@ -141,6 +141,10 @@ class ProviderRepository {
|
|||||||
if (exists == null) {
|
if (exists == null) {
|
||||||
await isar.providerConfigEntitys
|
await isar.providerConfigEntitys
|
||||||
.put(ProviderConfigEntity.fromModel(seed));
|
.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
@@ -1,7 +1,7 @@
|
|||||||
name: gel_rule_app
|
name: gel_rule_app
|
||||||
description: Local backend/core layer for a Flutter booru browser app.
|
description: Local backend/core layer for a Flutter booru browser app.
|
||||||
publish_to: "none"
|
publish_to: "none"
|
||||||
version: 1.0.1+9
|
version: 1.0.2+10
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.3.0 <4.0.0"
|
sdk: ">=3.3.0 <4.0.0"
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ void main() {
|
|||||||
'e926',
|
'e926',
|
||||||
'realbooru',
|
'realbooru',
|
||||||
]);
|
]);
|
||||||
|
expect(
|
||||||
|
providers.singleWhere((provider) => provider.id == 'realbooru').enabled,
|
||||||
|
isFalse,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('settings saveEnabledProviders updates provider configs', () async {
|
test('settings saveEnabledProviders updates provider configs', () async {
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ void main() {
|
|||||||
.where((provider) => provider.id == 'realbooru')
|
.where((provider) => provider.id == 'realbooru')
|
||||||
.single;
|
.single;
|
||||||
|
|
||||||
expect(realbooru.enabled, isTrue);
|
expect(realbooru.enabled, isFalse);
|
||||||
expect(realbooru.apiType, 'realbooru');
|
expect(realbooru.apiType, 'realbooru');
|
||||||
expect(realbooru.baseUrl, 'https://realbooru.com');
|
expect(realbooru.baseUrl, 'https://realbooru.com');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user