Server Update

This commit is contained in:
JacobTech 2024-08-27 10:57:46 -04:00
parent 900136ef76
commit 5c5b975b93
31 changed files with 518 additions and 58 deletions

View File

@ -0,0 +1,11 @@
namespace Luski.Shared.GlobalAttributes;
public class DisplayNameAttribute : Attribute
{
public DisplayNameAttribute(string DisplayName)
{
this.DisplayName = DisplayName;
}
public string DisplayName { get; private set; }
}

View File

@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Title>Luski.Shared</Title>
<Version>1.1.0-alpha21</Version>
<Version>1.1.0-alpha44</Version>
</PropertyGroup>
<ItemGroup>

View File

@ -1,5 +1,6 @@
using System.Text.Json.Serialization;
using JacobTechEncryption.Enums;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ClientToServer.HTTP;
@ -8,6 +9,9 @@ public class CategoryPostCTS : CTS
[JsonInclude]
[JsonPropertyName("parent")]
public long Parent { get; set; }
[JsonInclude]
[JsonPropertyName("color_type")]
public ColorType ColorType { get; set; } = ColorType.Full;
[JsonInclude]
[JsonPropertyName("color")]
@ -22,7 +26,7 @@ public class CategoryPostCTS : CTS
public string Description { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("role_overrides")]
public UserRoleOverrideCTS[] RoleOverrides { get; set; } = Array.Empty<UserRoleOverrideCTS>();
public RoleOverrideCTS[] RoleOverrides { get; set; } = Array.Empty<RoleOverrideCTS>();
[JsonInclude]
[JsonPropertyName("member_overrides")]
public UserOverrideCTS[] UserOverrides { get; set; } = Array.Empty<UserOverrideCTS>();

View File

@ -10,6 +10,9 @@ public class ChannelPostCTS : CTS
[JsonPropertyName("parent")]
public long Parent { get; set; }
[JsonInclude]
[JsonPropertyName("color_type")]
public ColorType ColorType { get; set; } = ColorType.Full;
[JsonInclude]
[JsonPropertyName("color")]
public string Color { get; set; } = string.Empty;
[JsonInclude]
@ -23,7 +26,7 @@ public class ChannelPostCTS : CTS
public string Description { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("role_overrides")]
public UserRoleOverrideCTS[] RoleOverrides { get; set; } = Array.Empty<UserRoleOverrideCTS>();
public RoleOverrideCTS[] RoleOverrides { get; set; } = Array.Empty<RoleOverrideCTS>();
[JsonInclude]
[JsonPropertyName("member_overrides")]
public UserOverrideCTS[] UserOverrides { get; set; } = Array.Empty<UserOverrideCTS>();

View File

@ -0,0 +1,25 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ClientToServer.HTTP;
public class RoleMembersPatchCTS : CTS
{
[JsonInclude]
[JsonPropertyName("id")]
public long ID { get; set; }
[JsonInclude]
[JsonPropertyName("removed_members")]
public long[] RemovedMembers { get; set; }
[JsonInclude]
[JsonPropertyName("added_members")]
public long[] AddedMembers { get; set; }
}
[JsonSerializable(typeof(RoleMembersPatchCTS))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class RoleMembersPatchCTSContext : JsonSerializerContext;

View File

@ -4,7 +4,7 @@ using Luski.Shared.PublicServers.V1.Shared;
namespace Luski.Shared.PublicServers.V1.ClientToServer.HTTP;
public class UserRoleOverrideCTS : CTS
public class RoleOverrideCTS : CTS
{
[JsonInclude]
[JsonPropertyName("role_id")]
@ -17,9 +17,9 @@ public class UserRoleOverrideCTS : CTS
public ServerPermission BadPermissions { get; set; }
}
[JsonSerializable(typeof(UserRoleOverrideCTS))]
[JsonSerializable(typeof(RoleOverrideCTS))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class UserRoleOverrideCTSContext : JsonSerializerContext;
public partial class RoleOverrideCTSContext : JsonSerializerContext;

View File

@ -0,0 +1,37 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ClientToServer.HTTP;
public class RolePatchCTS : CTS
{
[JsonInclude]
[JsonPropertyName("id")]
public long ID { get; set; }
[JsonInclude]
[JsonPropertyName("display_name")]
public string? DisplayName { get; set; }
[JsonInclude]
[JsonPropertyName("index")]
public int? Index { get; set; }
[JsonInclude]
[JsonPropertyName("color_type")]
public ColorType? ColorType { get; set; }
[JsonInclude]
[JsonPropertyName("color")]
public string? Color { get; set; }
[JsonInclude]
[JsonPropertyName("description")]
public string? Description { get; set; }
[JsonInclude]
[JsonPropertyName("server_permissions")]
public ServerPermission? ServerPermissions { get; set; }
}
[JsonSerializable(typeof(RolePatchCTS))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class RolePatchCTSContext : JsonSerializerContext;

View File

@ -0,0 +1,34 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ClientToServer.HTTP;
public class RolePostCTS : CTS
{
[JsonInclude]
[JsonPropertyName("display_name")]
public string DisplayName { get; set; } = string.Empty;
[JsonInclude]
[JsonPropertyName("index")]
public int Index { get; set; }
[JsonInclude]
[JsonPropertyName("color_type")]
public ColorType ColorType { get; set; } = ColorType.Full;
[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;
}
[JsonSerializable(typeof(RolePostCTS))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class RolePostCTSContext : JsonSerializerContext;

View File

@ -9,7 +9,6 @@ public class UserOverrideCTS : CTS
[JsonInclude]
[JsonPropertyName("user_id")]
public long UserID { get; set; }
[JsonInclude]
[JsonPropertyName("good_permissions")]
public ServerPermission GoodPermissions { get; set; }

View File

@ -0,0 +1,7 @@
namespace Luski.Shared.PublicServers.V1.Enums;
public enum ColorType
{
Full,
LeftToRightGradient
}

View File

@ -3,5 +3,12 @@ namespace Luski.Shared.PublicServers.V1.Enums;
public enum DataType
{
Token,
MessageCreate
MessageCreate,
MessageEdit,
MessageDelete,
StatusUpdate,
Role,
RoleMember,
RoleDelete,
}

View File

@ -1,48 +1,160 @@
using System.ComponentModel;
namespace Luski.Shared.PublicServers.V1.Enums;
[Flags]
public enum ServerPermission : long
{
/// <summary>
/// Internal permission for quick permission lookup
/// </summary>
None = 0b_0000000000000000000000000000000000000000000000000000000000000000,
/// <summary>
/// Internal permission for quick permission lookup.
/// </summary>
[Description("Internal permission for quick permission lookup")]
[GlobalAttributes.DisplayName("View This")]
[Category("Internal")]
ViewThis = 0b_0000000000000000000000000000000000000000000000000000000000000001,
[Description("User can view channels")]
[GlobalAttributes.DisplayName("View Channels")]
[Category("General")]
ViewChannels = 0b_0000000000000000000000000000000000000000000000000000000000000010,
[Description("User can move channels")]
[GlobalAttributes.DisplayName("Move Channels")]
[Category("General")]
MoveChannels = 0b_0000000000000000000000000000000000000000000000000000000000000100,
[Description("User can edit channels")]
[GlobalAttributes.DisplayName("Edit Channels")]
[Category("General")]
EditChannels = 0b_0000000000000000000000000000000000000000000000000000000000001000,
[Description("User can edit channel permissions")]
[GlobalAttributes.DisplayName("Edit Channel Permissions")]
[Category("General")]
EditChannelPermissions = 0b_0000000000000000000000000000000000000000000000000000000000010000,
[Description("User can create channels")]
[GlobalAttributes.DisplayName("Create Channels")]
[Category("General")]
CreateChannels = 0b_0000000000000000000000000000000000000000000000000000000000100000,
[Description("User can delete channels")]
[GlobalAttributes.DisplayName("Delete Channels")]
[Category("General")]
DeleteChannels = 0b_0000000000000000000000000000000000000000000000000000000001000000,
[Description("User can view categories")]
[GlobalAttributes.DisplayName("View Categories")]
[Category("General")]
ViewCategories = 0b_0000000000000000000000000000000000000000000000000000000010000000,
[Description("User can move categories")]
[GlobalAttributes.DisplayName("Move Categories")]
[Category("General")]
MoveCategories = 0b_0000000000000000000000000000000000000000000000000000000100000000,
[Description("User can edit categories")]
[GlobalAttributes.DisplayName("Edit Categories")]
[Category("General")]
EditCategories = 0b_0000000000000000000000000000000000000000000000000000001000000000,
[Description("User can edit category permissions")]
[GlobalAttributes.DisplayName("Edit Category Permissions")]
[Category("General")]
EditCategoryPermissions = 0b_0000000000000000000000000000000000000000000000000000010000000000,
[Description("User can create categories")]
[GlobalAttributes.DisplayName("Create Categories")]
[Category("General")]
CreateCategories = 0b_0000000000000000000000000000000000000000000000000000100000000000,
[Description("User can delete categories")]
[GlobalAttributes.DisplayName("Delete Categories")]
[Category("General")]
DeleteCategories = 0b_0000000000000000000000000000000000000000000000000001000000000000,
[Description("User can delete keys")]
[GlobalAttributes.DisplayName("Delete Keys")]
[Category("General")]
DeleteKeys = 0b_0000000000000000000000000000000000000000000000000010000000000000,
[Description("User can manage roles")]
[GlobalAttributes.DisplayName("Manage Roles")]
[Category("General")]
ManageRoles = 0b_0000000000000000000000000000000000000000000000000100000000000000,
[Description("User can view logs")]
[GlobalAttributes.DisplayName("View Logs")]
[Category("General")]
ViewLogs = 0b_0000000000000000000000000000000000000000000000001000000000000000,
[Description("User can manage the server")]
[GlobalAttributes.DisplayName("Manage Server")]
[Category("General")]
ManageServer = 0b_0000000000000000000000000000000000000000000000010000000000000000,
[Description("User can add servers")]
[GlobalAttributes.DisplayName("Add Servers")]
[Category("General")]
AddServers = 0b_0000000000000000000000000000000000000000000000100000000000000000,
[Description("User can remove servers")]
[GlobalAttributes.DisplayName("Remove Servers")]
[Category("General")]
RemoveServers = 0b_0000000000000000000000000000000000000000000001000000000000000000,
[Description("User can invite people to the server if invite codes are required")]
[GlobalAttributes.DisplayName("Invite")]
[Category("General")]
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,
[Description("User can kick people")]
[GlobalAttributes.DisplayName("Kick")]
[Category("General")]
Kick = 0b_0000000000000000000000000000000000000000000100000000000000000000,
[Description("User can ban people")]
[GlobalAttributes.DisplayName("Ban")]
[Category("General")]
Ban = 0b_0000000000000000000000000000000000000000001000000000000000000000,
[Description("User can send messages")]
[GlobalAttributes.DisplayName("Send Messages")]
[Category("Text Channel")]
SendMessages = 0b_0000000000000000000000000000000000000000010000000000000000000000,
[Description("User can send files")]
[GlobalAttributes.DisplayName("Send Files")]
[Category("Text Channel")]
SendFiles = 0b_0000000000000000000000000000000000000000100000000000000000000000,
[Description("User can ping channels")]
[GlobalAttributes.DisplayName("Ping Channels")]
[Category("Text Channel")]
ChannelPings = 0b_0000000000000000000000000000000000000001000000000000000000000000,
[Description("User can ping the server")]
[GlobalAttributes.DisplayName("Ping Server")]
[Category("Text Channel")]
ServerPings = 0b_0000000000000000000000000000000000000010000000000000000000000000,
[Description("User can ping people")]
[GlobalAttributes.DisplayName("Ping Someone")]
[Category("Text Channel")]
PingSomeone = 0b_0000000000000000000000000000000000000100000000000000000000000000,
[Description("User can manage messages")]
[GlobalAttributes.DisplayName("Manage Messages")]
[Category("Text Channel")]
ManageMessages = 0b_0000000000000000000000000000000000001000000000000000000000000000,
[Description("User can read message history")]
[GlobalAttributes.DisplayName("Read Message History")]
[Category("Text Channel")]
ReadMessageHistory = 0b_0000000000000000000000000000000000010000000000000000000000000000,
[Description("User can use commands")]
[GlobalAttributes.DisplayName("Use Commands")]
[Category("Text Channel")]
UseServerCommands = 0b_0000000000000000000000000000000000100000000000000000000000000000,
[Description("User can join voice chats")]
[GlobalAttributes.DisplayName("Join Voice")]
[Category("Voice Channel")]
JoinVoice = 0b_0000000000000000000000000000000001000000000000000000000000000000,
[Description("User can speak in voice")]
[GlobalAttributes.DisplayName("Speak In Voice")]
[Category("Voice Channel")]
SpeakInVoice = 0b_0000000000000000000000000000000010000000000000000000000000000000,
[Description("User can mute people in voice")]
[GlobalAttributes.DisplayName("Mute Members In Voice")]
[Category("Voice Channel")]
MuteMembers = 0b_0000000000000000000000000000000100000000000000000000000000000000,
[Description("User can defen people in voice")]
[GlobalAttributes.DisplayName("Deafen Members In Voice")]
[Category("Voice Channel")]
DeafenMembers = 0b_0000000000000000000000000000001000000000000000000000000000000000,
[Description("User can move people in voice")]
[GlobalAttributes.DisplayName("Move Members In Voice")]
[Category("Voice Channel")]
MoveMembers = 0b_0000000000000000000000000000010000000000000000000000000000000000,
[Description("User can manage profiles")]
[GlobalAttributes.DisplayName("Manage Profiles")]
[Category("Personalization")]
ManageProfiles = 0b_0000000000000000000000000000100000000000000000000000000000000000,
[Description("User can create profiles")]
[GlobalAttributes.DisplayName("Create Profiles")]
[Category("Personalization")]
CreateProfile = 0b_0000000000000000000000000001000000000000000000000000000000000000,
}

View File

@ -13,6 +13,9 @@ public class CategorySTC : STC
[JsonPropertyName("picture_type")]
public PictureType PictureType { get; set; }
[JsonInclude]
[JsonPropertyName("color_type")]
public ColorType ColorType { get; set; } = ColorType.Full;
[JsonInclude]
[JsonPropertyName("color")]
public string Color { get; set; } = string.Empty;
[JsonInclude]
@ -32,10 +35,10 @@ public class CategorySTC : STC
public long[] Channels { get; set; } = Array.Empty<long>();
[JsonInclude]
[JsonPropertyName("role_overrides")]
public long[] RoleOverrides { get; set; } = Array.Empty<long>();
public RoleOverrideSTC[] RoleOverrides { get; set; } = Array.Empty<RoleOverrideSTC>();
[JsonInclude]
[JsonPropertyName("member_overrides")]
public long[] UserOverrides { get; set; } = Array.Empty<long>();
public UserOverrideSTC[] UserOverrides { get; set; } = Array.Empty<UserOverrideSTC>();
[JsonInclude]
[JsonPropertyName("title_encryption_key")]
public long TitleEncryptionKey { get; set; }

View File

@ -13,6 +13,9 @@ public class ChannelSTC : STC
[JsonPropertyName("parent")]
public long Parent { get; set; }
[JsonInclude]
[JsonPropertyName("color_type")]
public ColorType ColorType { get; set; } = ColorType.Full;
[JsonInclude]
[JsonPropertyName("color")]
public string Color { get; set; } = string.Empty;
[JsonInclude]
@ -32,10 +35,10 @@ public class ChannelSTC : STC
[JsonInclude]
[JsonPropertyName("role_overrides")]
public long[] RoleOverrides { get; set; } = Array.Empty<long>();
public RoleOverrideSTC[] RoleOverrides { get; set; } = Array.Empty<RoleOverrideSTC>();
[JsonInclude]
[JsonPropertyName("member_overrides")]
public long[] UserOverrides { get; set; } = Array.Empty<long>();
public UserOverrideSTC[] UserOverrides { get; set; } = Array.Empty<UserOverrideSTC>();
[JsonInclude]
[JsonPropertyName("title_encryption_key")]
public long TitleEncryptionKey { get; set; }

View File

@ -9,12 +9,18 @@ public class MessageSTC : STC
[JsonPropertyName("id")]
public long ID { get; set; }
[JsonInclude]
[JsonPropertyName("timestamp")]
public long Timestamp { get; set; }
[JsonInclude]
[JsonPropertyName("channel_id")]
public long ChannelID { get; set; }
[JsonInclude]
[JsonPropertyName("author_id")]
public long AuthorID { get; set; }
[JsonInclude]
[JsonPropertyName("profile_id")]
public long ProfileID { get; set; }
[JsonInclude]
[JsonPropertyName("context")]
public string Context { get; set; } = string.Empty;
[JsonInclude]
@ -26,9 +32,6 @@ public class MessageSTC : STC
[JsonInclude]
[JsonPropertyName("encoder_type")]
public EncoderType EncoderType { get; set; }
[JsonInclude]
[JsonPropertyName("is_channel_profile")]
public bool IsProfile { get; set; }
}
[JsonSerializable(typeof(MessageSTC))]

View File

@ -0,0 +1,19 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class ProfileListSTC : STC
{
[JsonInclude]
[JsonPropertyName("profiles")]
public List<ProfileSTC> Profiles { get; set; } = default!;
}
[JsonSerializable(typeof(ProfileListSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
public partial class ProfileListSTCContext : JsonSerializerContext;

View File

@ -3,7 +3,7 @@ using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class ChannelProfileSTC : STC
public class ProfileSTC : STC
{
[JsonInclude]
[JsonPropertyName("id")]
@ -18,11 +18,23 @@ public class ChannelProfileSTC : STC
[JsonPropertyName("controllers")]
public long[] Controllers { get; set; } = default!;
[JsonInclude]
[JsonPropertyName("role_controllers")]
public long[] RoleControllers { get; set; } = default!;
[JsonInclude]
[JsonPropertyName("channels")]
public long[] Channels { get; set; } = default!;
[JsonInclude]
[JsonPropertyName("categories")]
public long[] Categories { get; set; } = default!;
[JsonInclude]
[JsonPropertyName("color_type")]
public ColorType? ColorType { get; set; }
[JsonInclude]
[JsonPropertyName("color")]
public string Color { get; set; } = string.Empty;
public string? Color { get; set; } = string.Empty;
}
[JsonSerializable(typeof(ChannelProfileSTC))]
[JsonSerializable(typeof(ProfileSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,

View File

@ -4,11 +4,8 @@ using Luski.Shared.PublicServers.V1.Shared;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
public class UserRoleOverrideSTC : STC
public class RoleOverrideSTC : STC
{
[JsonInclude]
[JsonPropertyName("id")]
public long Id { get; set; }
[JsonInclude]
[JsonPropertyName("role_id")]
public long RoleID { get; set; }
@ -20,9 +17,9 @@ public class UserRoleOverrideSTC : STC
public ServerPermission BadPermissions { get; set; }
}
[JsonSerializable(typeof(UserRoleOverrideSTC))]
[JsonSerializable(typeof(RoleOverrideSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class UserRoleOverrideSTCContext : JsonSerializerContext;
public partial class RoleOverrideSTCContext : JsonSerializerContext;

View File

@ -9,15 +9,15 @@ public class RoleSTC : STC
[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_type")]
public ColorType ColorType { get; set; } = ColorType.Full;
[JsonInclude]
[JsonPropertyName("color")]
public string Color { get; set; } = string.Empty;
[JsonInclude]

View File

@ -1,5 +1,4 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
@ -7,7 +6,7 @@ public class RolesSTC : STC
{
[JsonInclude]
[JsonPropertyName("roles")]
public RoleSTC[] Roles { get; set; }
public RoleSTC[] Roles { get; set; } = Array.Empty<RoleSTC>();
}
[JsonSerializable(typeof(RolesSTC))]

View File

@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
using Luski.Shared.PublicServers.V1.Shared;
namespace Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
@ -18,6 +19,9 @@ public class ServerInfoSTC : STC
[JsonPropertyName("owner")]
public long Owner { get; set; }
[JsonInclude]
[JsonPropertyName("picture_type")]
public PictureType PictureType { get; set; }
[JsonInclude]
[JsonPropertyName("alternate_servers")]
public ServerData[] AlternateServers { get; set; } =Array.Empty<ServerData>();
}

View File

@ -9,17 +9,14 @@ public class SocketUserSTC : STC
[JsonPropertyName("id")]
public long ID { get; set; }
[JsonInclude]
[JsonPropertyName("displayname")]
public string DisplayName { get; set; } = default!;
[JsonPropertyName("server_profile")]
public long ServerProfile { 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!;

View File

@ -6,9 +6,6 @@ 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; }

View File

@ -0,0 +1,14 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.ServerToClient.WSS;
public class WebsocketMessageSendEventSTC
{
[JsonPropertyName("type")]
[JsonInclude]
public DataType? Type { get; set; } = DataType.Token!;
[JsonPropertyName("error")]
[JsonInclude]
public string Error { get; set; } = default!;
}

View File

@ -0,0 +1,20 @@
using System.Text.Json.Serialization;
namespace Luski.Shared.PublicServers.V1.ServerToClient.WSS;
public class WebsocketTokenEventSTC : WebsocketMessageSendEventSTC
{
[JsonInclude]
[JsonPropertyName("token")]
public string Token { get; set; } = default!;
[JsonInclude]
[JsonPropertyName("session_token")]
public string? SessionToken { get; set; }
}
[JsonSerializable(typeof(WebsocketTokenEventSTC))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class WebsocketTokenEventSTCContext : JsonSerializerContext;

View File

@ -0,0 +1,3 @@
namespace Luski.Shared.PublicServers.V1.Shared;
public interface IServerEvent;

View File

@ -0,0 +1,43 @@
using System.Text.Json.Serialization;
using JacobTechEncryption.Enums;
using Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
namespace Luski.Shared.PublicServers.V1.Shared;
public class MessageEvent : IServerEvent
{
[JsonInclude]
[JsonPropertyName("author_id")]
public long AuthorID { get; set; }
[JsonInclude]
[JsonPropertyName("profile_id")]
public long ProfileID { get; set; }
[JsonInclude]
[JsonPropertyName("channel_id")]
public long ChannelID { get; set; }
[JsonInclude]
[JsonPropertyName("timestamp")]
public long Timestamp { get; set; }
[JsonInclude]
[JsonPropertyName("context")]
public string Base64Context { get; set; } = default!;
[JsonInclude]
[JsonPropertyName("id")]
public long ID { get; set; }
[JsonInclude]
[JsonPropertyName("files")]
public ServerFileInfoSTC[] Files { get; set; } = Array.Empty<ServerFileInfoSTC>();
[JsonInclude]
[JsonPropertyName("encryption_key")]
public long EncryptionKey { get; set; }
[JsonInclude]
[JsonPropertyName("encoder_type")]
public EncoderType EncoderType { get; set; }
}
[JsonSerializable(typeof(MessageEvent))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class MessageEventContext : JsonSerializerContext;

View File

@ -0,0 +1,37 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
using Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
namespace Luski.Shared.PublicServers.V1.Shared;
public class RoleEvent : IServerEvent
{
[JsonInclude]
[JsonPropertyName("id")]
public long ID { get; set; }
[JsonInclude]
[JsonPropertyName("display_name")]
public string? DisplayName { get; set; }
[JsonInclude]
[JsonPropertyName("index")]
public int? Index { get; set; }
[JsonInclude]
[JsonPropertyName("color_type")]
public ColorType? ColorType { get; set; }
[JsonInclude]
[JsonPropertyName("color")]
public string? Color { get; set; }
[JsonInclude]
[JsonPropertyName("description")]
public string? Description { get; set; }
[JsonInclude]
[JsonPropertyName("server_permissions")]
public ServerPermission? ServerPermissions { get; set; }
}
[JsonSerializable(typeof(RoleEvent))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class RoleEventContext : JsonSerializerContext;

View File

@ -0,0 +1,24 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
namespace Luski.Shared.PublicServers.V1.Shared;
public class RoleMemberEvent : IServerEvent
{
[JsonInclude]
[JsonPropertyName("id")]
public long ID { get; set; }
[JsonInclude]
[JsonPropertyName("removed_members")]
public long[] RemovedMembers { get; set; }
[JsonInclude]
[JsonPropertyName("added_members")]
public long[] AddedMembers { get; set; }
}
[JsonSerializable(typeof(RoleMemberEvent))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class RoleMemberEventContext : JsonSerializerContext;

View File

@ -0,0 +1,22 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.Shared;
public class ServerEvent
{
[JsonInclude]
[JsonPropertyName("type")]
public DataType Type { get; set; }
[JsonInclude]
[JsonPropertyName("data")]
public object Data { get; set; } = default!;
}
[JsonSerializable(typeof(ServerEvent))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class ServerEventContext : JsonSerializerContext;

View File

@ -0,0 +1,24 @@
using System.Text.Json.Serialization;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.Shared.PublicServers.V1.Shared;
public class StatusEvent : IServerEvent
{
[JsonInclude]
[JsonPropertyName("id")]
public long User { get; set; }
[JsonInclude]
[JsonPropertyName("before")]
public UserStatus Before { get; set; }
[JsonInclude]
[JsonPropertyName("after")]
public UserStatus After { get; set; }
}
[JsonSerializable(typeof(StatusEvent))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
WriteIndented = false)]
public partial class StatusEventContext : JsonSerializerContext;