Sync update: 2026-05-18 16:14:25

This commit is contained in:
Hamza-Ayed
2026-05-18 16:14:25 +03:00
parent 7b6e4b3111
commit 905819a1d5
9 changed files with 388 additions and 60 deletions

View File

@@ -215,6 +215,28 @@ class WhatsAppService extends GetxService {
Future<Map<String, dynamic>> sendFcmToken(String token) =>
_request({ 'type': 'register_fcm', 'token': token });
Future<Map<String, dynamic>> getMedia(String messageId) =>
_request({ 'type': 'get_media', 'messageId': messageId });
// Cache downloaded media: messageId -> base64
final RxMap<String, String> mediaCache = <String, String>{}.obs;
Future<String?> downloadAndCacheMedia(String messageId) async {
if (mediaCache.containsKey(messageId)) return mediaCache[messageId];
try {
final res = await getMedia(messageId);
if (res['type'] == 'media' && res['data'] != null) {
final String base64Data = res['data'];
mediaCache[messageId] = base64Data;
return base64Data;
}
} catch (e) {
print('[MEDIA DOWNLOAD ERROR] Failed to download message media: $e');
}
return null;
}
Future<Map<String, dynamic>> ping() =>
_request({ 'type': 'ping' });
}