dev #1

Merged
JacobTech merged 14 commits from dev into stable 2024-11-18 23:39:55 -05:00
10 changed files with 23 additions and 126 deletions
Showing only changes of commit f950957b76 - Show all commits

View File

@ -0,0 +1,10 @@
namespace Luski.net.Enums;
public enum ConnectionStatus
{
FailedToConnect,
CommunicationError,
FailedToLogin,
ConnectedNotLoggedIn,
LoggedIn,
}

View File

@ -13,11 +13,11 @@
<RepositoryUrl>https://github.com/JacobTech-com/Luski.net</RepositoryUrl> <RepositoryUrl>https://github.com/JacobTech-com/Luski.net</RepositoryUrl>
<IncludeSymbols>True</IncludeSymbols> <IncludeSymbols>True</IncludeSymbols>
<FileVersion>1.0.0</FileVersion> <FileVersion>1.0.0</FileVersion>
<Version>2.0.1-alpha15</Version> <Version>2.0.1-alpha18</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Luski.Shared" Version="1.1.0-alpha44" /> <PackageReference Include="Luski.Shared" Version="1.1.0-alpha48" />
<PackageReference Include="websocketsharp.core" Version="1.0.0" /> <PackageReference Include="websocketsharp.core" Version="1.0.0" />
</ItemGroup> </ItemGroup>

View File

@ -88,6 +88,7 @@ public partial class PublicServer
Console.WriteLine("Account Result: " + DateTime.UtcNow.Subtract(dt).ToString("g")); Console.WriteLine("Account Result: " + DateTime.UtcNow.Subtract(dt).ToString("g"));
if (json.Error is not null) if (json.Error is not null)
{ {
ConnectionStatus = ConnectionStatus.FailedToLogin;
Console.WriteLine(json.ErrorMessage); Console.WriteLine(json.ErrorMessage);
return false; return false;
throw new Exception($"Luski appears to be down at the current moment: {json.ErrorMessage}"); throw new Exception($"Luski appears to be down at the current moment: {json.ErrorMessage}");
@ -121,6 +122,7 @@ public partial class PublicServer
Token.Split('.')[0] Token.Split('.')[0]
))); )));
User = await GetUser<SocketAppUser>(id, CancellationToken); User = await GetUser<SocketAppUser>(id, CancellationToken);
ConnectionStatus = ConnectionStatus.LoggedIn;
User.Username = Username; User.Username = Username;
Console.WriteLine("Get our info: " + DateTime.UtcNow.Subtract(dt).ToString("g")); Console.WriteLine("Get our info: " + DateTime.UtcNow.Subtract(dt).ToString("g"));

View File

@ -101,9 +101,12 @@ public partial class PublicServer : Server
if (si is null) if (si is null)
{ {
Failed.Add(s); Failed.Add(s);
s.ConnectionStatus = ConnectionStatus.FailedToConnect;
throw; throw;
} }
} }
s.ConnectionStatus = ConnectionStatus.ConnectedNotLoggedIn;
s.Storage.SetJson(StorageDirectory.ServerInfo, "server.json", new() s.Storage.SetJson(StorageDirectory.ServerInfo, "server.json", new()
{ {
AlternateServers = Array.Empty<ServerData>(), AlternateServers = Array.Empty<ServerData>(),
@ -180,19 +183,6 @@ public partial class PublicServer : Server
Encryption.AES.Decrypt(Convert.FromBase64String(request.Name), nkey.Key)), Encryption.AES.Decrypt(Convert.FromBase64String(request.Name), nkey.Key)),
_ => Encryption.Generic.Encoders[(short)request.TitleEncoderType].GetString(Convert.FromBase64String(request.Name)) _ => Encryption.Generic.Encoders[(short)request.TitleEncoderType].GetString(Convert.FromBase64String(request.Name))
}; };
List<Color> cols = new();
if (request.ColorType == ColorType.Full)
{
Color nc = new(request.Color);
cols.Add(nc);
}
else
{
for (int i = 0; i < request.Color.Length - 7; i+=8)
{
cols.Add(new(request.Color[i..(i+8)]));
}
}
TCategory bob = new() TCategory bob = new()
{ {
@ -208,9 +198,7 @@ public partial class PublicServer : Server
UserOverides = request.UserOverrides, UserOverides = request.UserOverrides,
TitleEncoderType = request.TitleEncoderType, TitleEncoderType = request.TitleEncoderType,
TitleEncryptionKey = request.TitleEncryptionKey, TitleEncryptionKey = request.TitleEncryptionKey,
Server = this, Server = this
ColorType = request.ColorType,
Colors = cols.ToArray()
}; };
cats.Add(bob); cats.Add(bob);
return bob; return bob;
@ -528,19 +516,6 @@ public partial class PublicServer : Server
Encryption.AES.Decrypt(Convert.FromBase64String(request.Name), nkey.Key)), Encryption.AES.Decrypt(Convert.FromBase64String(request.Name), nkey.Key)),
_ => Encryption.Generic.Encoders[(short)request.TitleEncoderType].GetString(Convert.FromBase64String(request.Name)) _ => Encryption.Generic.Encoders[(short)request.TitleEncoderType].GetString(Convert.FromBase64String(request.Name))
}; };
List<Color> cols = new();
if (request.ColorType == ColorType.Full)
{
Color nc = new(request.Color);
cols.Add(nc);
}
else
{
for (int i = 0; i < request.Color.Length - 7; i+=8)
{
cols.Add(new(request.Color[i..(i+8)]));
}
}
TChannel bob = new() TChannel bob = new()
{ {
@ -560,8 +535,6 @@ public partial class PublicServer : Server
TitleEncryptionKey = request.TitleEncryptionKey, TitleEncryptionKey = request.TitleEncryptionKey,
PictureType = request.PictureType, PictureType = request.PictureType,
Server = this, Server = this,
ColorType = request.ColorType,
Colors = cols.ToArray()
}; };
chans.Add(bob); chans.Add(bob);
@ -595,25 +568,11 @@ public partial class PublicServer : Server
RoleOverrides = Array.Empty<RoleOverrideCTS>(), RoleOverrides = Array.Empty<RoleOverrideCTS>(),
UserOverrides = Array.Empty<UserOverrideCTS>(), UserOverrides = Array.Empty<UserOverrideCTS>(),
Type = ChannelType.TextAndVoice, Type = ChannelType.TextAndVoice,
Color = "FFFFFFFF",
PictureType = PictureType.none PictureType = PictureType.none
}, },
ChannelPostCTSContext.Default.ChannelPostCTS, ChannelPostCTSContext.Default.ChannelPostCTS,
ChannelSTCContext.Default.ChannelSTC, ChannelSTCContext.Default.ChannelSTC,
CancellationToken.None); CancellationToken.None);
List<Color> cols = new();
if (res.ColorType == ColorType.Full)
{
Color nc = new(res.Color);
cols.Add(nc);
}
else
{
for (int i = 0; i < res.Color.Length - 7; i+=8)
{
cols.Add(new(res.Color[i..(i+8)]));
}
}
return new SocketChannel() return new SocketChannel()
{ {
@ -632,9 +591,7 @@ public partial class PublicServer : Server
TitleEncoderType = res.TitleEncoderType, TitleEncoderType = res.TitleEncoderType,
TitleEncryptionKey = res.TitleEncryptionKey, TitleEncryptionKey = res.TitleEncryptionKey,
PictureType = res.PictureType, PictureType = res.PictureType,
Server = this, Server = this
ColorType = res.ColorType,
Colors = cols.ToArray()
}; };
} }
@ -795,26 +752,6 @@ public partial class PublicServer : Server
throw new Exception($"Something went wrong getting your user information\n{error}"); throw new Exception($"Something went wrong getting your user information\n{error}");
} }
Color[]? colss = null;
if (user.Color is not null)
{
List<Color> cols = new();
if (user.ColorType == ColorType.Full)
{
Color nc = new(user.Color);
cols.Add(nc);
}
else
{
for (int i = 0; i < user.Color.Length - 7; i+=8)
{
cols.Add(new(user.Color[i..(i+8)]));
}
}
colss = cols.ToArray();
}
ServerProfile u = new() ServerProfile u = new()
{ {
Server = this, Server = this,
@ -822,9 +759,7 @@ public partial class PublicServer : Server
DisplayName = user.DisplayName, DisplayName = user.DisplayName,
PictureType = user.PictureType, PictureType = user.PictureType,
Controllers = user.Controllers, Controllers = user.Controllers,
RoleControllers = user.RoleControllers, RoleControllers = user.RoleControllers
ColorType = user.ColorType,
Color = colss
}; };
profiles.Add(u); profiles.Add(u);
return u; return u;
@ -859,25 +794,6 @@ public partial class PublicServer : Server
throw new Exception($"Something went wrong getting your profile information\n{error}"); throw new Exception($"Something went wrong getting your profile information\n{error}");
} }
Color[]? colss = null;
if (user.Color is not null)
{
List<Color> cols = new();
if (user.ColorType == ColorType.Full)
{
Color nc = new(user.Color);
cols.Add(nc);
}
else
{
for (int i = 0; i < user.Color.Length - 7; i+=8)
{
cols.Add(new(user.Color[i..(i+8)]));
}
}
colss = cols.ToArray();
}
ServerProfile u = new() ServerProfile u = new()
{ {
Server = this, Server = this,
@ -885,9 +801,7 @@ public partial class PublicServer : Server
DisplayName = user.DisplayName, DisplayName = user.DisplayName,
PictureType = user.PictureType, PictureType = user.PictureType,
Controllers = user.Controllers, Controllers = user.Controllers,
RoleControllers = user.RoleControllers, RoleControllers = user.RoleControllers
ColorType = user.ColorType,
Color = colss
}; };
profiles_.Add(u); profiles_.Add(u);
profiles.Add(u); profiles.Add(u);

View File

@ -24,4 +24,5 @@ public partial class Server
internal bool CanRequest = false, login = false; internal bool CanRequest = false, login = false;
internal List<IUser> poeople = new(); internal List<IUser> poeople = new();
internal List<ServerProfile> profiles = new(); internal List<ServerProfile> profiles = new();
public ConnectionStatus ConnectionStatus { get; protected set; } = ConnectionStatus.FailedToConnect;
} }

View File

@ -26,11 +26,7 @@ public class MainSocketUserBase : STC, IUser
[JsonPropertyName("picture_type")] [JsonPropertyName("picture_type")]
[JsonInclude] [JsonInclude]
public PictureType PictureType { get; internal set; } = default!; public PictureType PictureType { get; internal set; } = default!;
public Task<Color> GetColor()
{
throw new NotImplementedException();
}
public async Task<Stream> GetAvatar(CancellationToken CancellationToken) public async Task<Stream> GetAvatar(CancellationToken CancellationToken)
{ {
bool isc = System.IO.File.Exists(Server.Storage.GetStorageDirectory(StorageDirectory.Avatars) + Id.ToString()); bool isc = System.IO.File.Exists(Server.Storage.GetStorageDirectory(StorageDirectory.Avatars) + Id.ToString());

View File

@ -15,18 +15,6 @@ public class ServerProfile
public PictureType? PictureType { get; init; } = default!; public PictureType? PictureType { get; init; } = default!;
public long[] Controllers { get; internal set; } = default!; public long[] Controllers { get; internal set; } = default!;
public long[] RoleControllers { get; internal set; } = default!; public long[] RoleControllers { get; internal set; } = default!;
internal ColorType? ColorType { get; set; } = default!;
internal Color[]? Color { get; set; } = default!;
public Task<Color[]?> GetColors()
{
return Task.FromResult(Color);
}
public Task<ColorType?> GetColorType()
{
return Task.FromResult(ColorType);
}
public async Task<Stream> GetAvatar(CancellationToken CancellationToken) public async Task<Stream> GetAvatar(CancellationToken CancellationToken)
{ {

View File

@ -12,8 +12,6 @@ public class SocketCategory
{ {
public PublicServer Server { get; init; } = default!; public PublicServer Server { get; init; } = default!;
public long ID { get; init; } public long ID { get; init; }
public ColorType ColorType { get; init; } = ColorType.Full;
public Color[] Colors { get; init; }
internal long ParentID { get; set; } internal long ParentID { get; set; }
internal RoleOverrideSTC[] RoleOverides { get; set; } internal RoleOverrideSTC[] RoleOverides { get; set; }
internal UserOverrideSTC[] UserOverides { get; set; } internal UserOverrideSTC[] UserOverides { get; set; }

View File

@ -15,8 +15,6 @@ namespace Luski.net.Structures.Public;
public class SocketChannel public class SocketChannel
{ {
public PublicServer Server { get; init; } = default!; public PublicServer Server { get; init; } = default!;
public ColorType ColorType { get; init; } = ColorType.Full;
public Color[] Colors { get; init; }
public long ID { get; internal set; } public long ID { get; internal set; }
internal long CategoryID { get; set; } internal long CategoryID { get; set; }
internal RoleOverrideSTC[] RoleOverrides { get; set; } internal RoleOverrideSTC[] RoleOverrides { get; set; }

View File

@ -22,16 +22,6 @@ public class SocketUser : IUser
public long[] RoleIds { get; init; } = default!; public long[] RoleIds { get; init; } = default!;
private List<Role>? RawRoles = null; private List<Role>? RawRoles = null;
public async Task<ColorType> GetColorType()
{
return (await GetRoles())[0].ColorType;
}
public async Task<Color[]> GetColors()
{
return (await GetRoles())[0].Colors;
}
public async Task<Role[]> GetRoles() public async Task<Role[]> GetRoles()
{ {
if (RawRoles is null) if (RawRoles is null)