Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

/ping to validate the endpoint

vishnukvmd7bb65af482f2
diff --git a/auth/lib/l10n/arb/app_en.arb b/auth/lib/l10n/arb/app_en.arb
index d01e657b4a..9f5674d853 100644
--- a/auth/lib/l10n/arb/app_en.arb
+++ b/auth/lib/l10n/arb/app_en.arb
@@ -409,11 +409,10 @@
"waitingForBrowserRequest": "Waiting for browser request...",
"launchPasskeyUrlAgain": "Launch passkey URL again",
"passkey": "Passkey",
- "developerMode":"Developer mode",
- "developerModeWarning":"Are you sure that you want to modify Developer settings?",
+ "developerSettingsWarning":"Are you sure that you want to modify Developer settings?",
"developerSettings": "Developer settings",
"serverEndpoint": "Server endpoint",
- "invalidURL": "Invalid URL",
- "invalidURLMessage": "Sorry, the URL you entered is invalid. Please enter a valid URL and try again.",
+ "invalidEndpoint": "Invalid endpoint",
+ "invalidEndpointMessage": "Sorry, the endpoint you entered is invalid. Please enter a valid endpoint and try again.",
"endpointUpdatedMessage": "Endpoint updated successfully"
}
\ No newline at end of file
diff --git a/auth/lib/onboarding/view/onboarding_page.dart b/auth/lib/onboarding/view/onboarding_page.dart
index 97b6f698c4..d8c359ecc4 100644
--- a/auth/lib/onboarding/view/onboarding_page.dart
+++ b/auth/lib/onboarding/view/onboarding_page.dart
@@ -68,9 +68,9 @@ class _OnboardingPageState extends State<OnboardingPage> {
_developerModeTapCount = 0;
final result = await showChoiceDialog(
context,
- title: l10n.developerMode,
+ title: l10n.developerSettings,
firstButtonLabel: l10n.yes,
- body: l10n.developerModeWarning,
+ body: l10n.developerSettingsWarning,
isDismissible: false,
);
if (result?.action == ButtonAction.first) {
diff --git a/auth/lib/ui/settings/developer_settings_page.dart b/auth/lib/ui/settings/developer_settings_page.dart
index 4b4a763974..1f263e5e9d 100644
--- a/auth/lib/ui/settings/developer_settings_page.dart
+++ b/auth/lib/ui/settings/developer_settings_page.dart
@@ -1,3 +1,4 @@
+import 'package:dio/dio.dart';
import 'package:ente_auth/core/configuration.dart';
import 'package:ente_auth/l10n/l10n.dart';
import 'package:ente_auth/ui/common/gradient_button.dart';
@@ -52,6 +53,7 @@ class _DeveloperSettingsPageState extends State<DeveloperSettingsPage> {
try {
final uri = Uri.parse(url);
if ((uri.scheme == "http" || uri.scheme == "https")) {
+ await _ping(url);
await Configuration.instance.setHttpEndpoint(url);
showToast(context, context.l10n.endpointUpdatedMessage);
Navigator.of(context).pop();
@@ -61,8 +63,8 @@ class _DeveloperSettingsPageState extends State<DeveloperSettingsPage> {
} catch (e) {
showErrorDialog(
context,
- context.l10n.invalidURL,
- context.l10n.invalidURLMessage,
+ context.l10n.invalidEndpoint,
+ context.l10n.invalidEndpointMessage,
);
}
},
@@ -73,4 +75,15 @@ class _DeveloperSettingsPageState extends State<DeveloperSettingsPage> {
),
);
}
+
+ Future<void> _ping(String endpoint) async {
+ try {
+ final response = await Dio().get(endpoint + '/ping');
+ if (response.data['message'] != 'pong') {
+ throw Exception('Invalid response');
+ }
+ } catch (e) {
+ throw Exception('Error occurred: $e');
+ }
+ }
}