TF-3157 Remove unnecessary background service worker

This commit is contained in:
DatDang
2024-11-04 16:28:13 +07:00
committed by Dat H. Pham
parent 7d59982cc9
commit b76e8bb725
20 changed files with 151 additions and 447 deletions
@@ -1,31 +0,0 @@
import 'package:json_annotation/json_annotation.dart';
part 'web_socket_echo.g.dart';
@JsonSerializable(includeIfNull: false)
class WebSocketEcho {
@JsonKey(name: '@type')
final String? type;
final String? requestId;
final List<List<dynamic>>? methodResponses;
WebSocketEcho({
this.type,
this.requestId,
this.methodResponses,
});
factory WebSocketEcho.fromJson(Map<String, dynamic> json) => _$WebSocketEchoFromJson(json);
Map<String, dynamic> toJson() => _$WebSocketEchoToJson(this);
static bool isValid(Map<String, dynamic> json) {
try {
final webSocketEcho = WebSocketEcho.fromJson(json);
final listResponses = webSocketEcho.methodResponses?.firstOrNull;
return listResponses?.contains('Core/echo') ?? false;
} catch (_) {
return false;
}
}
}
@@ -0,0 +1,19 @@
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
import 'package:tmail_ui_user/features/push_notification/data/model/web_socket_request.dart';
class WebSocketEchoRequest extends WebSocketRequest {
static const String type = 'Request';
static const String id = 'R1';
static final CapabilityIdentifier usingCapability = CapabilityIdentifier.jmapCore;
static const String method = 'Core/echo';
@override
Map<String, dynamic> toJson() {
return {
'@type': type,
'id': id,
'using': [usingCapability.value.toString()],
'methodCalls': [[method, {}, 'c0']],
};
}
}
@@ -0,0 +1,14 @@
import 'package:fcm/model/type_name.dart';
class WebSocketPushEnableRequest {
static const String type = 'WebSocketPushEnable';
static Map<String, dynamic> toJson({
required List<TypeName> dataTypes,
}) {
return {
'@type': type,
'dataTypes': dataTypes.map((typeName) => typeName.value).toList(),
};
}
}
@@ -0,0 +1,5 @@
abstract class WebSocketRequest {
const WebSocketRequest();
Map<String, dynamic> toJson();
}