Теперь можно жаловаться на сообщения!!!
This commit is contained in:
@@ -9,6 +9,7 @@ import 'package:gwid/connection/connection_logger.dart';
|
||||
import 'package:gwid/connection/connection_state.dart' as conn_state;
|
||||
import 'package:gwid/connection/health_monitor.dart';
|
||||
import 'package:gwid/image_cache_service.dart';
|
||||
import 'package:gwid/models/complaint.dart';
|
||||
import 'package:gwid/models/contact.dart';
|
||||
import 'package:gwid/models/message.dart';
|
||||
import 'package:gwid/models/profile.dart';
|
||||
@@ -31,6 +32,7 @@ part 'api_service_contacts.dart';
|
||||
part 'api_service_chats.dart';
|
||||
part 'api_service_media.dart';
|
||||
part 'api_service_privacy.dart';
|
||||
part 'api_service_complaints.dart';
|
||||
|
||||
class ApiService {
|
||||
ApiService._privateConstructor();
|
||||
@@ -85,9 +87,7 @@ class ApiService {
|
||||
|
||||
final Map<int, Contact> _contactCache = {};
|
||||
DateTime? _lastContactsUpdate;
|
||||
static const Duration _contactCacheExpiry = Duration(
|
||||
minutes: 5,
|
||||
);
|
||||
static const Duration _contactCacheExpiry = Duration(minutes: 5);
|
||||
|
||||
final CacheService _cacheService = CacheService();
|
||||
final AvatarCacheService _avatarCacheService = AvatarCacheService();
|
||||
@@ -295,4 +295,3 @@ class ApiService {
|
||||
_messageController.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
18
lib/api/api_service_complaints.dart
Normal file
18
lib/api/api_service_complaints.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
part of 'api_service.dart';
|
||||
|
||||
extension ApiServiceComplaints on ApiService {
|
||||
void getComplaints() {
|
||||
final payload = {"complainSync": 0};
|
||||
_sendMessage(162, payload);
|
||||
}
|
||||
|
||||
void sendComplaint(int chatId, String messageId, int typeId, int reasonId) {
|
||||
final payload = {
|
||||
"reasonId": reasonId,
|
||||
"parentId": chatId,
|
||||
"typeId": 3,
|
||||
"ids": [int.parse(messageId)], // Конвертируем в число
|
||||
};
|
||||
_sendMessage(161, payload);
|
||||
}
|
||||
}
|
||||
@@ -90,8 +90,8 @@ extension ApiServiceConnection on ApiService {
|
||||
print(
|
||||
'Используем ${proxySettings.protocol.name.toUpperCase()} прокси ${proxySettings.host}:${proxySettings.port}',
|
||||
);
|
||||
final customHttpClient =
|
||||
await ProxyService.instance.getHttpClientWithProxy();
|
||||
final customHttpClient = await ProxyService.instance
|
||||
.getHttpClientWithProxy();
|
||||
_channel = IOWebSocketChannel.connect(
|
||||
uri,
|
||||
headers: headers,
|
||||
@@ -166,7 +166,8 @@ extension ApiServiceConnection on ApiService {
|
||||
final userAgentPayload = await _buildUserAgentPayload();
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final deviceId = prefs.getString('spoof_deviceid') ?? generateRandomDeviceId();
|
||||
final deviceId =
|
||||
prefs.getString('spoof_deviceid') ?? generateRandomDeviceId();
|
||||
|
||||
if (prefs.getString('spoof_deviceid') == null) {
|
||||
await prefs.setString('spoof_deviceid', deviceId);
|
||||
@@ -335,8 +336,9 @@ extension ApiServiceConnection on ApiService {
|
||||
_log(loggableMessage);
|
||||
|
||||
try {
|
||||
final decodedMessage =
|
||||
message is String ? jsonDecode(message) : message;
|
||||
final decodedMessage = message is String
|
||||
? jsonDecode(message)
|
||||
: message;
|
||||
|
||||
if (decodedMessage is Map &&
|
||||
decodedMessage['opcode'] == 97 &&
|
||||
@@ -588,6 +590,23 @@ extension ApiServiceConnection on ApiService {
|
||||
});
|
||||
}
|
||||
|
||||
if (decodedMessage is Map &&
|
||||
decodedMessage['opcode'] == 162 &&
|
||||
decodedMessage['cmd'] == 1) {
|
||||
final payload = decodedMessage['payload'];
|
||||
print('Получены данные жалоб: $payload');
|
||||
|
||||
try {
|
||||
final complaintData = ComplaintData.fromJson(payload);
|
||||
_messageController.add({
|
||||
'type': 'complaints_data',
|
||||
'complaintData': complaintData,
|
||||
});
|
||||
} catch (e) {
|
||||
print('Ошибка парсинга данных жалоб: $e');
|
||||
}
|
||||
}
|
||||
|
||||
if (decodedMessage is Map<String, dynamic>) {
|
||||
_messageController.add(decodedMessage);
|
||||
}
|
||||
@@ -783,4 +802,3 @@ extension ApiServiceConnection on ApiService {
|
||||
_connectionStatusController.add("disconnected");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user