✨ Wallet funds
This commit is contained in:
@@ -27,7 +27,7 @@ public class RingServiceGrpc(
|
||||
public override Task<Empty> PushWebSocketPacket(PushWebSocketPacketRequest request, ServerCallContext context)
|
||||
{
|
||||
var packet = Shared.Models.WebSocketPacket.FromProtoValue(request.Packet);
|
||||
|
||||
|
||||
WebSocketService.SendPacketToAccount(Guid.Parse(request.UserId), packet);
|
||||
return Task.FromResult(new Empty());
|
||||
}
|
||||
@@ -36,18 +36,18 @@ public class RingServiceGrpc(
|
||||
ServerCallContext context)
|
||||
{
|
||||
var packet = Shared.Models.WebSocketPacket.FromProtoValue(request.Packet);
|
||||
|
||||
|
||||
foreach (var accountId in request.UserIds)
|
||||
WebSocketService.SendPacketToAccount(Guid.Parse(accountId), packet);
|
||||
|
||||
|
||||
return Task.FromResult(new Empty());
|
||||
}
|
||||
|
||||
public override Task<Empty> PushWebSocketPacketToDevice(PushWebSocketPacketToDeviceRequest request,
|
||||
ServerCallContext context)
|
||||
public override Task<Empty> PushWebSocketPacketToDevice(PushWebSocketPacketToDeviceRequest request,
|
||||
ServerCallContext context)
|
||||
{
|
||||
var packet = Shared.Models.WebSocketPacket.FromProtoValue(request.Packet);
|
||||
|
||||
|
||||
websocket.SendPacketToDevice(request.DeviceId, packet);
|
||||
return Task.FromResult(new Empty());
|
||||
}
|
||||
@@ -56,10 +56,10 @@ public override Task<Empty> PushWebSocketPacketToDevice(PushWebSocketPacketToDev
|
||||
ServerCallContext context)
|
||||
{
|
||||
var packet = Shared.Models.WebSocketPacket.FromProtoValue(request.Packet);
|
||||
|
||||
|
||||
foreach (var deviceId in request.DeviceIds)
|
||||
websocket.SendPacketToDevice(deviceId, packet);
|
||||
|
||||
|
||||
return Task.FromResult(new Empty());
|
||||
}
|
||||
|
||||
@@ -77,19 +77,19 @@ public override Task<Empty> PushWebSocketPacketToDevice(PushWebSocketPacketToDev
|
||||
: [],
|
||||
AccountId = Guid.Parse(request.UserId),
|
||||
};
|
||||
|
||||
|
||||
if (request.Notification.ActionUri is not null)
|
||||
notification.Meta["action_uri"] = request.Notification.ActionUri;
|
||||
|
||||
if (request.Notification.IsSavable)
|
||||
await pushService.SaveNotification(notification);
|
||||
|
||||
|
||||
await queueService.EnqueuePushNotification(
|
||||
notification,
|
||||
Guid.Parse(request.UserId),
|
||||
request.Notification.IsSavable
|
||||
);
|
||||
|
||||
|
||||
return new Empty();
|
||||
}
|
||||
|
||||
@@ -106,21 +106,21 @@ public override Task<Empty> PushWebSocketPacketToDevice(PushWebSocketPacketToDev
|
||||
? GrpcTypeHelper.ConvertByteStringToObject<Dictionary<string, object?>>(request.Notification.Meta) ?? []
|
||||
: [],
|
||||
};
|
||||
|
||||
|
||||
if (request.Notification.ActionUri is not null)
|
||||
notification.Meta["action_uri"] = request.Notification.ActionUri;
|
||||
|
||||
var userIds = request.UserIds.Select(Guid.Parse).ToList();
|
||||
if (request.Notification.IsSavable)
|
||||
await pushService.SaveNotification(notification, userIds);
|
||||
|
||||
|
||||
var tasks = userIds
|
||||
.Select(userId => queueService.EnqueuePushNotification(
|
||||
notification,
|
||||
userId,
|
||||
request.Notification.IsSavable
|
||||
));
|
||||
|
||||
|
||||
await Task.WhenAll(tasks);
|
||||
return new Empty();
|
||||
}
|
||||
|
@@ -2,10 +2,8 @@ using System.Text.Json;
|
||||
using DysonNetwork.Ring.Email;
|
||||
using DysonNetwork.Ring.Notification;
|
||||
using DysonNetwork.Shared.Proto;
|
||||
using DysonNetwork.Shared.Stream;
|
||||
using Google.Protobuf;
|
||||
using NATS.Client.Core;
|
||||
using NATS.Net;
|
||||
|
||||
namespace DysonNetwork.Ring.Services;
|
||||
|
||||
@@ -37,7 +35,7 @@ public class QueueBackgroundService(
|
||||
private async Task RunConsumerAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
logger.LogInformation("Queue consumer started");
|
||||
|
||||
|
||||
await foreach (var msg in nats.SubscribeAsync<byte[]>(QueueName, queueGroup: QueueGroup, cancellationToken: stoppingToken))
|
||||
{
|
||||
try
|
||||
@@ -105,7 +103,7 @@ public class QueueBackgroundService(
|
||||
{
|
||||
var pushService = scope.ServiceProvider.GetRequiredService<PushService>();
|
||||
var logger = scope.ServiceProvider.GetRequiredService<ILogger<QueueBackgroundService>>();
|
||||
|
||||
|
||||
var notification = JsonSerializer.Deserialize<Shared.Models.SnNotification>(message.Data);
|
||||
if (notification == null)
|
||||
{
|
||||
@@ -117,4 +115,4 @@ public class QueueBackgroundService(
|
||||
await pushService.DeliverPushNotification(notification, cancellationToken);
|
||||
logger.LogDebug("Successfully processed push notification for account {AccountId}", notification.AccountId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user