using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using JacobTechEncryption.Enums; using Luski.net.Interfaces; namespace Luski.net.Structures.Public; public class SocketMessage { public required PublicServer Server { get; init; } = default!; public required long ID { get; init; } public required long TimeStamp { get; init; } public required long ChannelID { get; init; } public required long AuthorID { get; init; } public required long ProfileID { get; init; } public string Context { get; internal set; } public required long EncryptionKey { get; init; } public long[] FileIDs { get; internal set; } public EncoderType EncoderType { get; internal set; } private SocketChannel? RawParent; private IUser? au; private ServerProfile? ap; internal List _Files { get; set; } = new(); public IReadOnlyList Files { get => _Files.AsReadOnly(); } public async Task GetParent(CancellationToken token) { if (RawParent is null) { RawParent = await Server.GetChannel(ChannelID, token); } return RawParent; } public async Task GetAuthor(CancellationToken token) { if (au is null) { if (AuthorID == Server.User.Id) au = Server.User; else au = await Server.GetUser(AuthorID, token); } return au; } public async Task GetProfile(CancellationToken token) { if (ap is null) { ap = await Server.GetProfile(ProfileID, token); } return ap; } }