HTTP Communications

This commit is contained in:
JacobTech 2024-03-20 23:16:24 -04:00
parent 60ec7c30a8
commit e4c99d0186
39 changed files with 1081 additions and 0 deletions

79
.gitignore vendored Normal file
View File

@ -0,0 +1,79 @@
# ---> JetBrains
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

16
Luski.Shared.sln Normal file
View File

@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Luski.Shared", "Luski.Shared\Luski.Shared.csproj", "{9B23658F-7986-4F90-BC9A-BAC04433797B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9B23658F-7986-4F90-BC9A-BAC04433797B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B23658F-7986-4F90-BC9A-BAC04433797B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B23658F-7986-4F90-BC9A-BAC04433797B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B23658F-7986-4F90-BC9A-BAC04433797B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Title>Luski.Shared</Title>
<Version>1.1.0-alpha19</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JacobTechEncryption" Version="1.0.2" />
</ItemGroup>
<ItemGroup>
<Folder Include="PublicServers\V1\" />
</ItemGroup>
<Target Name="CustomActionsAfterPublish" AfterTargets="Pack">
<Message Text="Actions AfterPublish: $(PackageId).$(PackageVersion).nupkg" Importance="high" />
<Exec Command="nuget push -Source https://nuget.jacobtech.com/v3/index.json bin/Release/$(PackageId).$(PackageVersion).nupkg" />
</Target>
</Project>

View File

@ -0,0 +1,12 @@
using System.Text.Json.Serialization;
namespace Luski.Shared.PublicServers.V1.ClientToServer.HTTP;
public class CTS;
[JsonSerializable(typeof(CTS))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class CTSContext : JsonSerializerContext;

View File

@ -0,0 +1,48 @@
using System.Text.Json.Serialization;
using JacobTechEncryption.Enums;
namespace Luski.Shared.PublicServers.V1.ClientToServer.HTTP;
public class CategoryPostCTS : CTS
{
[JsonInclude]
[JsonPropertyName("parent")]
public long Parent { get; set; }
[JsonInclude]
[JsonPropertyName("color")]
public string Color { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("description")]
public string Description { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("role_overrides")]
public UserRoleOverrideCTS[] RoleOverrides { get; set; } = Array.Empty<UserRoleOverrideCTS>();
[JsonInclude]
[JsonPropertyName("member_overrides")]
public UserOverrideCTS[] UserOverrides { get; set; } = Array.Empty<UserOverrideCTS>();
[JsonInclude]
[JsonPropertyName("title_encryption_key")]
public long TitleEncryptionKey { get; set; }
[JsonInclude]
[JsonPropertyName("description_encryption_key")]
public long DescriptionEncryptionKey { get; set; }
[JsonInclude]
[JsonPropertyName("title_encoder_type")]
public EncoderType TitleEncoderType { get; set; }
[JsonInclude]
[JsonPropertyName("description_encoder_type")]
public EncoderType DescriptionEncoderType { get; set; }
}
[JsonSerializable(typeof(CategoryPostCTS))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class CategoryPostCTSContext : JsonSerializerContext;

View File

@ -0,0 +1,58 @@
using System.Text.Json.Serialization;
using JacobTechEncryption.Enums;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ClientToServer.HTTP;
public class ChannelPostCTS : CTS
{
[JsonInclude]
[JsonPropertyName("parent")]
public long Parent { get; set; }
[JsonInclude]
[JsonPropertyName("color")]
public string Color { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("type")]
public ChannelType Type { get; set; } = ChannelType.TextAndVoice;
[JsonInclude]
[JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("description")]
public string Description { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("role_overrides")]
public UserRoleOverrideCTS[] RoleOverrides { get; set; } = Array.Empty<UserRoleOverrideCTS>();
[JsonInclude]
[JsonPropertyName("member_overrides")]
public UserOverrideCTS[] UserOverrides { get; set; } = Array.Empty<UserOverrideCTS>();
[JsonInclude]
[JsonPropertyName("title_encryption_key")]
public long TitleEncryptionKey { get; set; }
[JsonInclude]
[JsonPropertyName("description_encryption_key")]
public long DescriptionEncryptionKey { get; set; }
[JsonInclude]
[JsonPropertyName("encryption_keys")]
public long[] EncryptionKeys { get; set; } = Array.Empty<long>();
[JsonInclude]
[JsonPropertyName("title_encoder_type")]
public EncoderType TitleEncoderType { get; set; }
[JsonInclude]
[JsonPropertyName("description_encoder_type")]
public EncoderType DescriptionEncoderType { get; set; }
[JsonInclude]
[JsonPropertyName("encoder_types")]
public EncoderType[] EncoderTypes { get; set; } = Array.Empty<EncoderType>();
[JsonInclude]
[JsonPropertyName("picture_type")]
public PictureType PictureType { get; set; }
}
[JsonSerializable(typeof(ChannelPostCTS))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class ChannelPostCTSContext : JsonSerializerContext;

View File

@ -0,0 +1,22 @@
using System.Text.Json.Serialization;
using JacobTechEncryption.Enums;
namespace Luski.Shared.PublicServers.V1.ClientToServer.HTTP;
public class KeyPostCTS : CTS
{
[JsonInclude]
[JsonPropertyName("encryption_type")]
public EncryptionType EncryptionType { get; set; }
[JsonInclude]
[JsonPropertyName("key_data")]
public string Data { get; set; } = string.Empty;
}
[JsonSerializable(typeof(KeyPostCTS))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class KeyPostCTSContext : JsonSerializerContext;

View File

@ -0,0 +1,34 @@
using System.Text.Json.Serialization;
using JacobTechEncryption.Enums;
namespace Luski.Shared.PublicServers.V1.ClientToServer.HTTP;
public class MessageCTS : CTS
{
[JsonInclude]
[JsonPropertyName("author_id")]
public long? Profile { get; set; }
[JsonInclude]
[JsonPropertyName("channel_id")]
public long ChannelID { get; set; }
[JsonInclude]
[JsonPropertyName("context")]
public string Base64Context { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("files")]
public long[] Files { get; set; } = Array.Empty<long>();
[JsonInclude]
[JsonPropertyName("encryption_key")]
public long EncryptionKey { get; set; }
[JsonInclude]
[JsonPropertyName("encoding")]
public EncoderType Encoding { get; set; }
}
[JsonSerializable(typeof(MessageCTS))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class MessageCTSContext : JsonSerializerContext;

View File

@ -0,0 +1,18 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ClientToServer.HTTP;
public class StatusUpdateCTS : CTS
{
[JsonInclude]
[JsonPropertyName("status")]
public UserStatus Status { get; set; }
}
[JsonSerializable(typeof(StatusUpdateCTS))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class StatusUpdateCTSContext : JsonSerializerContext;

View File

@ -0,0 +1,17 @@
using System.Text.Json.Serialization;
namespace Luski.Shared.PublicServers.V1.ClientToServer.HTTP;
public class StorageInfoCTS : CTS
{
[JsonInclude]
[JsonPropertyName("password")]
public string Password { get; set; } = string.Empty;
}
[JsonSerializable(typeof(StorageInfoCTS))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class StorageInfoCTSContext : JsonSerializerContext;

View File

@ -0,0 +1,26 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
using Luski.Shared.PublicServers.V1.Shared;
namespace Luski.Shared.PublicServers.V1.ClientToServer.HTTP;
public class UserOverrideCTS : CTS
{
[JsonInclude]
[JsonPropertyName("user_id")]
public long UserID { get; set; }
[JsonInclude]
[JsonPropertyName("good_permissions")]
public ServerPermission GoodPermissions { get; set; }
[JsonInclude]
[JsonPropertyName("bad_permissions")]
public ServerPermission BadPermissions { get; set; }
}
[JsonSerializable(typeof(UserOverrideCTS))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class UserOverrideCTSContext : JsonSerializerContext;

View File

@ -0,0 +1,25 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
using Luski.Shared.PublicServers.V1.Shared;
namespace Luski.Shared.PublicServers.V1.ClientToServer.HTTP;
public class UserRoleOverrideCTS : CTS
{
[JsonInclude]
[JsonPropertyName("role_id")]
public long RoleID { get; set; }
[JsonInclude]
[JsonPropertyName("good_permissions")]
public ServerPermission GoodPermissions { get; set; }
[JsonInclude]
[JsonPropertyName("bad_permissions")]
public ServerPermission BadPermissions { get; set; }
}
[JsonSerializable(typeof(UserRoleOverrideCTS))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class UserRoleOverrideCTSContext : JsonSerializerContext;

View File

@ -0,0 +1,6 @@
namespace Luski.Shared.PublicServers.V1.ClientToServer.WSS;
public interface ICTWEvent
{
}

View File

@ -0,0 +1,10 @@
using System.Text.Json.Serialization;
namespace Luski.Shared.PublicServers.V1.ClientToServer.WSS;
public class LoginCTW : ICTWEvent
{
[JsonPropertyName("token")]
[JsonInclude]
public string Token { get; set; } = default!;
}

View File

@ -0,0 +1,6 @@
namespace Luski.Shared.PublicServers.V1.Enums;
public enum ChannelType : short
{
TextAndVoice = 0
}

View File

@ -0,0 +1,7 @@
namespace Luski.Shared.PublicServers.V1.Enums;
public enum DataType
{
Token,
MessageCreate
}

View File

@ -0,0 +1,14 @@
namespace Luski.Shared.PublicServers.V1.Enums;
public enum ErrorCode
{
MissingToken,
InvalidToken,
MissingPostData,
InvalidPostData,
Forbidden,
ServerError,
MissingHeader,
InvalidHeader,
InvalidURL
}

View File

@ -0,0 +1,14 @@
namespace Luski.Shared.PublicServers.V1.Enums;
public enum PictureType : short
{
none,
png,
jpeg,
bmp,
gif,
ico,
svg,
tif,
webp
}

View File

@ -0,0 +1,48 @@
namespace Luski.Shared.PublicServers.V1.Enums;
[Flags]
public enum ServerPermission : long
{
/// <summary>
/// Internal permission for quick permission lookup
/// </summary>
None = 0b_0000000000000000000000000000000000000000000000000000000000000000,
ViewThis = 0b_0000000000000000000000000000000000000000000000000000000000000001,
ViewChannels = 0b_0000000000000000000000000000000000000000000000000000000000000010,
MoveChannels = 0b_0000000000000000000000000000000000000000000000000000000000000100,
EditChannels = 0b_0000000000000000000000000000000000000000000000000000000000001000,
EditChannelPermissions = 0b_0000000000000000000000000000000000000000000000000000000000010000,
CreateChannels = 0b_0000000000000000000000000000000000000000000000000000000000100000,
DeleteChannels = 0b_0000000000000000000000000000000000000000000000000000000001000000,
ViewCategories = 0b_0000000000000000000000000000000000000000000000000000000010000000,
MoveCategories = 0b_0000000000000000000000000000000000000000000000000000000100000000,
EditCategories = 0b_0000000000000000000000000000000000000000000000000000001000000000,
EditCategoryPermissions = 0b_0000000000000000000000000000000000000000000000000000010000000000,
CreateCategories = 0b_0000000000000000000000000000000000000000000000000000100000000000,
DeleteCategories = 0b_0000000000000000000000000000000000000000000000000001000000000000,
DeleteKeys = 0b_0000000000000000000000000000000000000000000000000010000000000000,
ManageRoles = 0b_0000000000000000000000000000000000000000000000000100000000000000,
ViewLogs = 0b_0000000000000000000000000000000000000000000000001000000000000000,
ManageServer = 0b_0000000000000000000000000000000000000000000000010000000000000000,
AddServers = 0b_0000000000000000000000000000000000000000000000100000000000000000,
RemoveServers = 0b_0000000000000000000000000000000000000000000001000000000000000000,
Invite = 0b_0000000000000000000000000000000000000000000010000000000000000000,
Nickname = 0b_0000000000000000000000000000000000000000000100000000000000000000,
ManageNicknames = 0b_0000000000000000000000000000000000000000001000000000000000000000,
Kick = 0b_0000000000000000000000000000000000000000010000000000000000000000,
Ban = 0b_0000000000000000000000000000000000000000100000000000000000000000,
SendMessages = 0b_0000000000000000000000000000000000000001000000000000000000000000,
SendFiles = 0b_0000000000000000000000000000000000000010000000000000000000000000,
ChannelPings = 0b_0000000000000000000000000000000000000100000000000000000000000000,
ServerPings = 0b_0000000000000000000000000000000000001000000000000000000000000000,
PingSomeone = 0b_0000000000000000000000000000000000010000000000000000000000000000,
ManageMessages = 0b_0000000000000000000000000000000000100000000000000000000000000000,
ReadMessageHistory = 0b_0000000000000000000000000000000001000000000000000000000000000000,
UseServerCommands = 0b_0000000000000000000000000000000010000000000000000000000000000000,
JoinVoice = 0b_0000000000000000000000000000000100000000000000000000000000000000,
SpeakInVoice = 0b_0000000000000000000000000000001000000000000000000000000000000000,
MuteMembers = 0b_0000000000000000000000000000010000000000000000000000000000000000,
DeafenMembers = 0b_0000000000000000000000000000100000000000000000000000000000000000,
MoveMembers = 0b_0000000000000000000000000001000000000000000000000000000000000000,
ManageChannelProfiles = 0b_0000000000000000000000000010000000000000000000000000000000000000,
}

View File

@ -0,0 +1,11 @@
namespace Luski.Shared.PublicServers.V1.Enums;
public enum UserStatus : short
{
Offline,
Online,
Idle,
DoNotDisturb,
Invisible,
MAX
}

View File

@ -0,0 +1,59 @@
using System.Text.Json.Serialization;
using JacobTechEncryption.Enums;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class CategorySTC : STC
{
[JsonInclude]
[JsonPropertyName("id")]
public long ID { get; set; }
[JsonInclude]
[JsonPropertyName("picture_type")]
public PictureType PictureType { get; set; }
[JsonInclude]
[JsonPropertyName("color")]
public string Color { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("description")]
public string Description { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("parent")]
public long Parent { get; set; }
[JsonInclude]
[JsonPropertyName("inner_categories")]
public long[] InnerCategories { get; set; } = Array.Empty<long>();
[JsonInclude]
[JsonPropertyName("channels")]
public long[] Channels { get; set; } = Array.Empty<long>();
[JsonInclude]
[JsonPropertyName("role_overrides")]
public long[] RoleOverrides { get; set; } = Array.Empty<long>();
[JsonInclude]
[JsonPropertyName("member_overrides")]
public long[] UserOverrides { get; set; } = Array.Empty<long>();
[JsonInclude]
[JsonPropertyName("title_encryption_key")]
public long TitleEncryptionKey { get; set; }
[JsonInclude]
[JsonPropertyName("description_encryption_key")]
public long DescriptionEncryptionKey { get; set; }
[JsonInclude]
[JsonPropertyName("title_encoder_type")]
public EncoderType TitleEncoderType { get; set; }
[JsonInclude]
[JsonPropertyName("description_encoder_type")]
public EncoderType DescriptionEncoderType { get; set; }
}
[JsonSerializable(typeof(CategorySTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class CategorySTCContext : JsonSerializerContext;

View File

@ -0,0 +1,31 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class ChannelProfileSTC : STC
{
[JsonInclude]
[JsonPropertyName("id")]
public long ID { get; set; } = default!;
[JsonInclude]
[JsonPropertyName("displayname")]
public string DisplayName { get; set; } = default!;
[JsonInclude]
[JsonPropertyName("picture_type")]
public PictureType PictureType { get; set; } = default!;
[JsonInclude]
[JsonPropertyName("controllers")]
public long[] Controllers { get; set; } = default!;
[JsonInclude]
[JsonPropertyName("color")]
public string Color { get; set; } = string.Empty;
}
[JsonSerializable(typeof(ChannelProfileSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class ChannelProfileSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,74 @@
using System.Text.Json.Serialization;
using JacobTechEncryption.Enums;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class ChannelSTC : STC
{
[JsonInclude]
[JsonPropertyName("id")]
public long ID { get; set; }
[JsonInclude]
[JsonPropertyName("parent")]
public long Parent { get; set; }
[JsonInclude]
[JsonPropertyName("color")]
public string Color { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("type")]
public ChannelType Type { get; set; }
[JsonInclude]
[JsonPropertyName("epoch")]
public DateTime Epoch { get; set; }
[JsonInclude]
[JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("description")]
public string Description { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("role_overrides")]
public long[] RoleOverrides { get; set; } = Array.Empty<long>();
[JsonInclude]
[JsonPropertyName("member_overrides")]
public long[] UserOverrides { get; set; } = Array.Empty<long>();
[JsonInclude]
[JsonPropertyName("title_encryption_key")]
public long TitleEncryptionKey { get; set; }
[JsonInclude]
[JsonPropertyName("description_encryption_key")]
public long DescriptionEncryptionKey { get; set; }
[JsonInclude]
[JsonPropertyName("encryption_keys")]
public long[] EncryptionKeys { get; set; } = Array.Empty<long>();
[JsonInclude]
[JsonPropertyName("title_encoder_type")]
public EncoderType TitleEncoderType { get; set; }
[JsonInclude]
[JsonPropertyName("description_encoder_type")]
public EncoderType DescriptionEncoderType { get; set; }
[JsonInclude]
[JsonPropertyName("encoder_types")]
public EncoderType[] EncoderTypes { get; set; } = Array.Empty<EncoderType>();
[JsonInclude]
[JsonPropertyName("picture_type")]
public PictureType PictureType { get; set; }
[JsonInclude]
[JsonPropertyName("encoder_blacklist")]
public bool IsEncoderBlacklist { get; set; }
[JsonInclude]
[JsonPropertyName("encryption_blacklist")]
public bool IsEncryptionBlacklist { get; set; }
}
[JsonSerializable(typeof(ChannelSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class ChannelSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,29 @@
using System.Text.Json.Serialization;
using JacobTechEncryption.Enums;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class KeyGetSTC : STC
{
[JsonInclude]
[JsonPropertyName("id")]
public long ID { get; set; }
[JsonInclude]
[JsonPropertyName("owner")]
public long Owner { get; set; }
[JsonInclude]
[JsonPropertyName("encryption_type")]
public EncryptionType EncryptionType { get; set; }
[JsonInclude]
[JsonPropertyName("key_data")]
public string Data { get; set; } = string.Empty;
}
[JsonSerializable(typeof(KeyGetSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class KeyGetSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,18 @@
using System.Text.Json.Serialization;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class KeysGetSTC : STC
{
[JsonInclude]
[JsonPropertyName("keys")]
public KeyGetSTC[] Keys { get; set; } = Array.Empty<KeyGetSTC>();
}
[JsonSerializable(typeof(KeysGetSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class KeysGetSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,18 @@
using System.Text.Json.Serialization;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class LoginSTC : STC
{
[JsonInclude]
[JsonPropertyName("login_token")]
public string Token { get; set; } = default!;
}
[JsonSerializable(typeof(LoginSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class LoginSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,40 @@
using System.Text.Json.Serialization;
using JacobTechEncryption.Enums;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class MessageSTC : STC
{
[JsonInclude]
[JsonPropertyName("id")]
public long ID { get; set; }
[JsonInclude]
[JsonPropertyName("channel_id")]
public long ChannelID { get; set; }
[JsonInclude]
[JsonPropertyName("author_id")]
public long AuthorID { get; set; }
[JsonInclude]
[JsonPropertyName("context")]
public string Context { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("encryption_key")]
public long EncryptionKey { get; set; }
[JsonInclude]
[JsonPropertyName("files")]
public ServerFileInfoSTC[] Files { get; set; } = Array.Empty<ServerFileInfoSTC>();
[JsonInclude]
[JsonPropertyName("encoder_type")]
public EncoderType EncoderType { get; set; }
[JsonInclude]
[JsonPropertyName("is_channel_profile")]
public bool IsProfile { get; set; }
}
[JsonSerializable(typeof(MessageSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class MessageSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,18 @@
using System.Text.Json.Serialization;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class OfflineDataBlobSTC : STC
{
[JsonInclude]
[JsonPropertyName("data")]
public string[] Data { get; set; } = Array.Empty<string>();
}
[JsonSerializable(typeof(OfflineDataBlobSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class OfflineDataBlobSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,40 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class RoleSTC : STC
{
[JsonInclude]
[JsonPropertyName("id")]
public long ID { get; set; }
[JsonInclude]
[JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("display_name")]
public string DisplayName { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("index")]
public int Index { get; set; }
[JsonInclude]
[JsonPropertyName("color")]
public string Color { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("description")]
public string Description { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("server_permissions")]
public ServerPermission ServerPermissions { get; set; } = ServerPermission.None;
[JsonInclude]
[JsonPropertyName("members_list")]
public long[] Members { get; set; } = Array.Empty<long>();
}
[JsonSerializable(typeof(RoleSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class RoleSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,27 @@
using System.ComponentModel;
using System.Net;
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public class STC
{
[JsonPropertyName("error")]
[JsonInclude]
public ErrorCode? Error { get; set; }
[JsonIgnore]
public HttpStatusCode StatusCode { get; init; } = HttpStatusCode.OK;
[JsonPropertyName("error_message")]
[JsonInclude]
public string? ErrorMessage { get; set; }
}
[JsonSerializable(typeof(STC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class STCContext : JsonSerializerContext;

View File

@ -0,0 +1,37 @@
using System.Text.Json.Serialization;
using JacobTechEncryption.Enums;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class ServerFileInfoSTC : STC
{
[JsonInclude]
[JsonPropertyName("id")]
public long ID { get; set; }
[JsonInclude]
[JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("encoder_type")]
public EncoderType Encoder { get; set; }
[JsonInclude]
[JsonPropertyName("name_encoder_type")]
public EncoderType NameEncoder { get; set; }
[JsonInclude]
[JsonPropertyName("encryption_key")]
public long Key { get; set; }
[JsonInclude]
[JsonPropertyName("name_encryption_key")]
public long NameKey { get; set; }
[JsonInclude]
[JsonPropertyName("size")]
public long Size { get; set; }
}
[JsonSerializable(typeof(ServerFileInfoSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class ServerFileInfoSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,31 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Shared;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class ServerInfoSTC : STC
{
[JsonInclude]
[JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("wssv4")]
public string WSSv4Address { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("description")]
public string Description { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("owner")]
public long Owner { get; set; }
[JsonInclude]
[JsonPropertyName("alternate_servers")]
public ServerData[] AlternateServers { get; set; } =Array.Empty<ServerData>();
}
[JsonSerializable(typeof(ServerInfoSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class ServerInfoSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,18 @@
using System.Text.Json.Serialization;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class SocketBulkMessageSTC : STC
{
[JsonInclude]
[JsonPropertyName("messages")]
public MessageSTC[]? Messages { get; set; } = default!;
}
[JsonSerializable(typeof(SocketBulkMessageSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class SocketBulkMessageSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,34 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class SocketUserSTC : STC
{
[JsonInclude]
[JsonPropertyName("id")]
public long ID { get; set; }
[JsonInclude]
[JsonPropertyName("displayname")]
public string DisplayName { get; set; } = default!;
[JsonInclude]
[JsonPropertyName("selected_channel")]
public long SelectedChannel { get; set; }
[JsonInclude]
[JsonPropertyName("status")]
public UserStatus Status { get; set; }
[JsonInclude]
[JsonPropertyName("picture_type")]
public PictureType PictureType { get; set; }
[JsonInclude]
[JsonPropertyName("roles")]
public long[] RoleIds { get; set; } = default!;
}
[JsonSerializable(typeof(SocketUserSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class SocketUserSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,24 @@
using System.Text.Json.Serialization;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class StorageInfoSTC : STC
{
[JsonInclude]
[JsonPropertyName("id")]
public long ID { get; set; }
[JsonInclude]
[JsonPropertyName("update")]
public bool Update { get; set; }
[JsonInclude]
[JsonPropertyName("password")]
public string Password { get; set; } = string.Empty;
}
[JsonSerializable(typeof(StorageInfoSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class StorageInfoSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,28 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
using Luski.Shared.PublicServers.V1.Shared;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class UserOverrideSTC : STC
{
[JsonInclude]
[JsonPropertyName("id")]
public long Id { get; set; }
[JsonInclude]
[JsonPropertyName("user_id")]
public long UserID { get; set; }
[JsonInclude]
[JsonPropertyName("good_permissions")]
public ServerPermission GoodPermissions { get; set; }
[JsonInclude]
[JsonPropertyName("bad_permissions")]
public ServerPermission BadPermissions { get; set; }
}
[JsonSerializable(typeof(UserOverrideSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class UserOverrideSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,28 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
using Luski.Shared.PublicServers.V1.Shared;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class UserRoleOverrideSTC : STC
{
[JsonInclude]
[JsonPropertyName("id")]
public long Id { get; set; }
[JsonInclude]
[JsonPropertyName("role_id")]
public long RoleID { get; set; }
[JsonInclude]
[JsonPropertyName("good_permissions")]
public ServerPermission GoodPermissions { get; set; }
[JsonInclude]
[JsonPropertyName("bad_permissions")]
public ServerPermission BadPermissions { get; set; }
}
[JsonSerializable(typeof(UserRoleOverrideSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class UserRoleOverrideSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,12 @@
using System.Data;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.Shared;
public static class Ext
{
public static bool HasPermission(this ServerPermission Full, ServerPermission Permission)
{
return ((long) Full & (long) Permission) == (long) Permission;
}
}

View File

@ -0,0 +1,20 @@
using System.Text.Json.Serialization;
namespace Luski.Shared.PublicServers.V1.Shared;
public class ServerData
{
[JsonInclude]
[JsonPropertyName("address")]
public string DomainAndPort = default!;
[JsonInclude]
[JsonPropertyName("secure")]
public bool Secure;
}
[JsonSerializable(typeof(ServerData))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class ServerDataContext : JsonSerializerContext;