using DeluxeBackend.Models; using System.Numerics; using System.Security.Claims; using static DeluxeBackend.Enums; namespace DeluxeBackend.Services { public interface IMessageService { Task 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 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; } } }