105 lines
3.2 KiB
C#
105 lines
3.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using JacobTechEncryption.Enums;
|
|
using Luski.Shared.PublicServers.V1.Enums;
|
|
using Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
|
|
|
|
namespace Luski.net.Structures.Public;
|
|
|
|
public class SocketCategory
|
|
{
|
|
public PublicServer Server { get; init; } = default!;
|
|
public long ID { get; init; }
|
|
internal long ParentID { get; set; }
|
|
internal RoleOverrideSTC[] RoleOverides { get; set; }
|
|
internal UserOverrideSTC[] UserOverides { get; set; }
|
|
internal long[] Channels { get; set; }
|
|
internal long[] Categories { get; set; }
|
|
SocketCategory? RawParent = null;
|
|
List<RoleOverride>? RawRoleOverides = null;
|
|
List<UserOverride>? RawUserOverides = null;
|
|
List<SocketChannel>? RawChan = null;
|
|
List<SocketCategory>? RawCat = null;
|
|
|
|
public async Task<SocketCategory?> GetParent()
|
|
{
|
|
if (ParentID != -1 && RawParent is null)
|
|
{
|
|
RawParent = await Server.GetCategory<SocketCategory>(ParentID, CancellationToken.None);
|
|
}
|
|
|
|
return RawParent;
|
|
}
|
|
|
|
public async Task<SocketChannel[]> GetChannels()
|
|
{
|
|
if (RawChan is null)
|
|
{
|
|
RawChan = new();
|
|
foreach (long chan in Channels)
|
|
{
|
|
RawChan.Add(await Server.GetChannel<SocketChannel>(chan, CancellationToken.None));
|
|
}
|
|
}
|
|
|
|
if (RawChan.Count != Channels.Length)
|
|
{
|
|
foreach (long chan in Channels)
|
|
{
|
|
if (RawChan.Any(s => s.ID == chan)) continue;
|
|
RawChan.Add(await Server.GetChannel<SocketChannel>(chan, CancellationToken.None));
|
|
}
|
|
}
|
|
|
|
return RawChan.ToArray();
|
|
}
|
|
public async Task<SocketCategory[]> GetCategories()
|
|
{
|
|
if (RawCat is null)
|
|
{
|
|
RawCat = new();
|
|
foreach (long chan in Categories)
|
|
{
|
|
RawCat.Add(await Server.GetCategory<SocketCategory>(chan, CancellationToken.None));
|
|
}
|
|
}
|
|
|
|
if (RawCat.Count != Channels.Length)
|
|
{
|
|
foreach (long chan in Categories)
|
|
{
|
|
if (RawCat.Any(s => s.ID == chan)) continue;
|
|
RawCat.Add(await Server.GetCategory<SocketCategory>(chan, CancellationToken.None));
|
|
}
|
|
}
|
|
|
|
return RawCat.ToArray();
|
|
}
|
|
public string Name { get; internal set; }
|
|
public string Description { get; internal set; }
|
|
|
|
public Task<RoleOverride[]> GetRoleOverrides()
|
|
{
|
|
if (RawRoleOverides is null)
|
|
{
|
|
RawRoleOverides = new();
|
|
}
|
|
|
|
return Task.FromResult(RawRoleOverides!.ToArray());
|
|
}
|
|
public Task<UserOverride[]> GetUserOverrides()
|
|
{
|
|
if (RawUserOverides is null)
|
|
{
|
|
RawUserOverides = new();
|
|
}
|
|
|
|
return Task.FromResult(RawUserOverides!.ToArray());
|
|
}
|
|
public long TitleEncryptionKey { get; internal set; }
|
|
public long DescriptionEncryptionKey { get; internal set; }
|
|
public EncoderType TitleEncoderType { get; internal set; }
|
|
public EncoderType DescriptionEncoderType { get; internal set; }
|
|
} |