♻️ Centralized data models (wip)

This commit is contained in:
2025-09-27 14:09:28 +08:00
parent 51b6f7309e
commit e70d8371f8
206 changed files with 1352 additions and 2128 deletions

View File

@@ -25,7 +25,7 @@ public class RingServiceGrpc(
public override Task<Empty> PushWebSocketPacket(PushWebSocketPacketRequest request, ServerCallContext context)
{
var packet = Shared.Data.WebSocketPacket.FromProtoValue(request.Packet);
var packet = Shared.Models.WebSocketPacket.FromProtoValue(request.Packet);
WebSocketService.SendPacketToAccount(Guid.Parse(request.UserId), packet);
return Task.FromResult(new Empty());
@@ -34,7 +34,7 @@ public class RingServiceGrpc(
public override Task<Empty> PushWebSocketPacketToUsers(PushWebSocketPacketToUsersRequest request,
ServerCallContext context)
{
var packet = Shared.Data.WebSocketPacket.FromProtoValue(request.Packet);
var packet = Shared.Models.WebSocketPacket.FromProtoValue(request.Packet);
foreach (var accountId in request.UserIds)
WebSocketService.SendPacketToAccount(Guid.Parse(accountId), packet);
@@ -45,7 +45,7 @@ public class RingServiceGrpc(
public override Task<Empty> PushWebSocketPacketToDevice(PushWebSocketPacketToDeviceRequest request,
ServerCallContext context)
{
var packet = Shared.Data.WebSocketPacket.FromProtoValue(request.Packet);
var packet = Shared.Models.WebSocketPacket.FromProtoValue(request.Packet);
websocket.SendPacketToDevice(request.DeviceId, packet);
return Task.FromResult(new Empty());
@@ -54,7 +54,7 @@ public override Task<Empty> PushWebSocketPacketToDevice(PushWebSocketPacketToDev
public override Task<Empty> PushWebSocketPacketToDevices(PushWebSocketPacketToDevicesRequest request,
ServerCallContext context)
{
var packet = Shared.Data.WebSocketPacket.FromProtoValue(request.Packet);
var packet = Shared.Models.WebSocketPacket.FromProtoValue(request.Packet);
foreach (var deviceId in request.DeviceIds)
websocket.SendPacketToDevice(deviceId, packet);

View File

@@ -119,7 +119,7 @@ public class QueueBackgroundService(
var pushService = scope.ServiceProvider.GetRequiredService<PushService>();
var logger = scope.ServiceProvider.GetRequiredService<ILogger<QueueBackgroundService>>();
var notification = JsonSerializer.Deserialize<Notification.Notification>(message.Data);
var notification = JsonSerializer.Deserialize<Shared.Models.SnNotification>(message.Data);
if (notification == null)
{
logger.LogError("Invalid push notification data format");

View File

@@ -26,7 +26,7 @@ public class QueueService(INatsConnection nats)
await js.PublishAsync(QueueBackgroundService.QueueName, rawMessage);
}
public async Task EnqueuePushNotification(Notification.Notification notification, Guid userId, bool isSavable = false)
public async Task EnqueuePushNotification(Shared.Models.SnNotification notification, Guid userId, bool isSavable = false)
{
// Update the account ID in case it wasn't set
notification.AccountId = userId;