fix upload: parse nested message.url, backup retries=1, connect.php auth

This commit is contained in:
Hamza-Ayed
2026-06-25 04:30:52 +03:00
parent 0b9e5dfa03
commit 75e4524329
3 changed files with 14 additions and 8 deletions

View File

@@ -359,11 +359,11 @@ class RegistrationController extends GetxController {
String link, {
String? backupLink,
}) async {
const int maxRetries = 3;
final List<String> urlsToTry = [link, if (backupLink != null && backupLink.trim().isNotEmpty) backupLink];
for (final currentUrl in urlsToTry) {
for (int i = 0; i < urlsToTry.length; i++) {
final currentUrl = urlsToTry[i];
final maxRetries = (i == 0) ? 3 : 1; // 3 attempts for primary, 1 for backup
for (int attempt = 1; attempt <= maxRetries; attempt++) {
try {
final uri = Uri.parse(currentUrl);
@@ -399,7 +399,15 @@ class RegistrationController extends GetxController {
}
final body = jsonDecode(res.body);
final String? url = body['url'] ??
String? url;
// بعض السيرفرات تعيد الرابط داخل message
if (body['message'] is Map) {
url = body['message']['url'] ??
body['message']['file_link'] ??
body['message']['image_url'];
}
// وإلا حاول من الجذر
url ??= body['url'] ??
body['file_link'] ??
body['image_url'] ??
(body['data'] is Map ? body['data']['url'] : null);