Files
VORTEX-REC-LEAK/Services/MessageService.cs
T
2026-07-23 18:21:43 -07:00

36 lines
1.1 KiB
C#

using DeluxeBackend.Models;
using System.Numerics;
using System.Security.Claims;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Services
{
public interface IMessageService
{
Task<Message> SendMessage(Account fromPlayer, Account toPlayer, MessageType type, string data);
}
public class MessageService(ILiteDbService db, IConfiguration configuration, INotificationService ws) : IMessageService
{
private readonly ILiteDbService _db = db;
private readonly IConfiguration _configuration = configuration;
private readonly INotificationService _ws = ws;
public async Task<Message> SendMessage(Account fromPlayer, Account toPlayer, MessageType type, string data)
{
var message = new Message
{
Player = toPlayer,
FromPlayer = fromPlayer,
Type = type,
Data = data
};
_db.Messages.Insert(message);
await _ws.SendToPlayer(toPlayer.Id, PushNotification.MessageReceived, message.ToDictionary());
return message;
}
}
}