Luski.Net/Luski.net/Structures/Public/SocketMessage.cs
JacobTech 9f641e7429 Public Servers.
Added a bunch of API calls to use in public servers.
2023-08-21 10:58:17 -04:00

49 lines
1.4 KiB
C#

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 PublicServer Server { get; init; } = default!;
public long ID { get; internal set; }
public long ChannelID { get; internal set; }
public long AuthorID { get; internal set; }
public long TimeStamp { get; internal set; }
public string Context { get; internal set; }
public long EncryptionKey { get; internal set; }
public long[] FileIDs { get; internal set; }
public EncoderType EncoderType { get; internal set; }
private SocketChannel? RawParent;
private IUser? au;
internal List<SocketFile> _Files = new();
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)
{
if (AuthorID == Server.User.Id) au = Server.User;
else au = await Server.GetUser<SocketUser>(ChannelID, token);
}
return au;
}
}