2023-08-21 10:58:17 -04:00
|
|
|
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
|
|
|
|
{
|
2024-03-20 23:18:34 -04:00
|
|
|
public required PublicServer Server { get; init; } = default!;
|
|
|
|
public required long ID { get; init; }
|
2024-08-27 10:57:22 -04:00
|
|
|
public required long TimeStamp { get; init; }
|
2024-03-20 23:18:34 -04:00
|
|
|
public required long ChannelID { get; init; }
|
|
|
|
public required long AuthorID { get; init; }
|
2024-08-27 10:57:22 -04:00
|
|
|
public required long ProfileID { get; init; }
|
2023-08-21 10:58:17 -04:00
|
|
|
public string Context { get; internal set; }
|
2024-03-20 23:18:34 -04:00
|
|
|
public required long EncryptionKey { get; init; }
|
2023-08-21 10:58:17 -04:00
|
|
|
public long[] FileIDs { get; internal set; }
|
|
|
|
public EncoderType EncoderType { get; internal set; }
|
|
|
|
private SocketChannel? RawParent;
|
|
|
|
private IUser? au;
|
2024-08-27 10:57:22 -04:00
|
|
|
private ServerProfile? ap;
|
|
|
|
internal List<SocketFile> _Files { get; set; } = new();
|
|
|
|
|
2023-08-21 10:58:17 -04:00
|
|
|
public IReadOnlyList<SocketFile> Files
|
|
|
|
{
|
|
|
|
get => _Files.AsReadOnly();
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<SocketChannel> GetParent(CancellationToken token)
|
|
|
|
{
|
|
|
|
if (RawParent is null)
|
|
|
|
{
|
|
|
|
RawParent = await Server.GetChannel<SocketChannel>(ChannelID, token);
|
|
|
|
}
|
|
|
|
|
|
|
|
return RawParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<IUser> GetAuthor(CancellationToken token)
|
|
|
|
{
|
|
|
|
if (au is null)
|
|
|
|
{
|
2024-08-27 10:57:22 -04:00
|
|
|
if (AuthorID == Server.User.Id) au = Server.User;
|
|
|
|
else au = await Server.GetUser<SocketUser>(AuthorID, token);
|
2023-08-21 10:58:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return au;
|
|
|
|
}
|
2024-08-27 10:57:22 -04:00
|
|
|
|
|
|
|
public async Task<ServerProfile> GetProfile(CancellationToken token)
|
|
|
|
{
|
|
|
|
if (ap is null)
|
|
|
|
{
|
|
|
|
ap = await Server.GetProfile(ProfileID, token);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ap;
|
|
|
|
}
|
2023-08-21 10:58:17 -04:00
|
|
|
}
|