feat: add E2EE DMs, group chats, local serversettings.json, and security/perf fixes
This commit is contained in:
parent
b60b5a0774
commit
3b52de20d1
33 changed files with 5107 additions and 366 deletions
|
|
@ -8,6 +8,8 @@ public class RegisterRequest
|
|||
public string Password { get; set; } = string.Empty;
|
||||
public string? ServerPassword { get; set; }
|
||||
public string? InviteToken { get; set; }
|
||||
public string? PublicKey { get; set; }
|
||||
public string? EncryptedPrivateKey { get; set; }
|
||||
}
|
||||
|
||||
public class LoginRequest
|
||||
|
|
@ -15,6 +17,8 @@ public class LoginRequest
|
|||
public string Username { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public string? ServerPassword { get; set; }
|
||||
public string? PublicKey { get; set; }
|
||||
public string? EncryptedPrivateKey { get; set; }
|
||||
}
|
||||
|
||||
public class AuthResponse
|
||||
|
|
@ -24,6 +28,9 @@ public class AuthResponse
|
|||
public string? UserId { get; set; }
|
||||
public string? Username { get; set; }
|
||||
public string? Role { get; set; }
|
||||
public string? PublicKey { get; set; }
|
||||
public string? EncryptedPrivateKey { get; set; }
|
||||
public bool E2eeEnabled { get; set; } = true;
|
||||
public string? ErrorMessage { get; set; }
|
||||
}
|
||||
|
||||
|
|
@ -36,6 +43,8 @@ public class ServerInfoResponse
|
|||
public string Motd { get; set; } = "Welcome to GsDChat!";
|
||||
public long MaxFileSizeMb { get; set; } = 50;
|
||||
public bool AllowMemberChannelCreation { get; set; } = true;
|
||||
public bool AllowDmE2ee { get; set; } = true;
|
||||
public int MaxGroupChatUsers { get; set; } = 10;
|
||||
}
|
||||
|
||||
public class UploadFileResponse
|
||||
|
|
|
|||
|
|
@ -17,6 +17,13 @@ public static class MessageTypes
|
|||
public const string ChannelListSync = "CHANNEL_LIST_SYNC";
|
||||
public const string CreateChannel = "CREATE_CHANNEL";
|
||||
public const string DeleteChannel = "DELETE_CHANNEL";
|
||||
public const string StartDm = "START_DM";
|
||||
public const string CreateGroup = "CREATE_GROUP";
|
||||
public const string InviteToGroup = "INVITE_TO_GROUP";
|
||||
public const string LeaveGroup = "LEAVE_GROUP";
|
||||
public const string PublishPublicKey = "PUBLISH_PUBLIC_KEY";
|
||||
public const string ToggleE2ee = "TOGGLE_E2EE";
|
||||
public const string FetchHistory = "FETCH_HISTORY";
|
||||
public const string UserListSync = "USER_LIST_SYNC";
|
||||
public const string FileListSync = "FILE_LIST_SYNC";
|
||||
public const string SystemNotice = "SYSTEM_NOTICE";
|
||||
|
|
@ -68,6 +75,9 @@ public class AuthResultPacket
|
|||
public string UserId { get; set; } = string.Empty;
|
||||
public string Username { get; set; } = string.Empty;
|
||||
public string Role { get; set; } = UserRoles.Member;
|
||||
public string? PublicKey { get; set; }
|
||||
public string? EncryptedPrivateKey { get; set; }
|
||||
public bool E2eeEnabled { get; set; } = true;
|
||||
public string? ErrorMessage { get; set; }
|
||||
public ServerUiSync? UiSync { get; set; }
|
||||
public string? ActiveChannelId { get; set; }
|
||||
|
|
@ -77,6 +87,9 @@ public class SendMessagePacket
|
|||
{
|
||||
public string ChannelId { get; set; } = string.Empty;
|
||||
public string Content { get; set; } = string.Empty;
|
||||
public bool IsEncrypted { get; set; } = false;
|
||||
public string? SenderPublicKey { get; set; }
|
||||
public string? RecipientPublicKey { get; set; }
|
||||
}
|
||||
|
||||
public class MessageBroadcastPacket
|
||||
|
|
@ -88,6 +101,16 @@ public class HistorySyncPacket
|
|||
{
|
||||
public string ChannelId { get; set; } = string.Empty;
|
||||
public List<ChatMessage> Messages { get; set; } = new();
|
||||
public bool Prepend { get; set; } = false;
|
||||
public bool HasMore { get; set; } = false;
|
||||
public int Offset { get; set; } = 0;
|
||||
}
|
||||
|
||||
public class FetchHistoryPacket
|
||||
{
|
||||
public string ChannelId { get; set; } = string.Empty;
|
||||
public int Offset { get; set; } = 0;
|
||||
public int Limit { get; set; } = 50;
|
||||
}
|
||||
|
||||
public class JoinChannelPacket
|
||||
|
|
@ -98,6 +121,8 @@ public class JoinChannelPacket
|
|||
public class ChannelListSyncPacket
|
||||
{
|
||||
public List<Channel> Channels { get; set; } = new();
|
||||
public List<Channel> DirectMessages { get; set; } = new();
|
||||
public List<Channel> GroupChats { get; set; } = new();
|
||||
public string ActiveChannelId { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
|
|
@ -112,12 +137,53 @@ public class DeleteChannelPacket
|
|||
public string ChannelId { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class StartDmPacket
|
||||
{
|
||||
public string TargetUserId { get; set; } = string.Empty;
|
||||
public string TargetUsername { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class CreateGroupPacket
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Topic { get; set; } = string.Empty;
|
||||
public List<string> MemberUsernames { get; set; } = new();
|
||||
public int? MaxUsers { get; set; }
|
||||
}
|
||||
|
||||
public class InviteToGroupPacket
|
||||
{
|
||||
public string ChannelId { get; set; } = string.Empty;
|
||||
public string TargetUsername { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class LeaveGroupPacket
|
||||
{
|
||||
public string ChannelId { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class PublishPublicKeyPacket
|
||||
{
|
||||
public string PublicKey { get; set; } = string.Empty;
|
||||
public string? EncryptedPrivateKey { get; set; }
|
||||
public bool ResetKeys { get; set; } = false;
|
||||
}
|
||||
|
||||
public class ToggleE2eePacket
|
||||
{
|
||||
public string Scope { get; set; } = "dm"; // "dm" or "account"
|
||||
public string? ChannelId { get; set; }
|
||||
public bool Enabled { get; set; } = true;
|
||||
}
|
||||
|
||||
public class UserSummary
|
||||
{
|
||||
public string Id { get; set; } = string.Empty;
|
||||
public string Username { get; set; } = string.Empty;
|
||||
public string Role { get; set; } = UserRoles.Member;
|
||||
public bool IsOnline { get; set; }
|
||||
public string? PublicKey { get; set; }
|
||||
public bool E2eeEnabled { get; set; } = true;
|
||||
}
|
||||
|
||||
public class UserListSyncPacket
|
||||
|
|
@ -164,4 +230,5 @@ public class CommandResultPacket
|
|||
{
|
||||
public bool Success { get; set; }
|
||||
public string Output { get; set; } = string.Empty;
|
||||
public string ChannelId { get; set; } = string.Empty;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,15 +38,23 @@ public class ServerUiSync
|
|||
{
|
||||
public string ServerName { get; set; } = "GsDChat Server";
|
||||
public string Motd { get; set; } = "Welcome to GsDChat!";
|
||||
public bool AllowDmE2ee { get; set; } = true;
|
||||
public int MaxGroupChatUsers { get; set; } = 10;
|
||||
public ThemeDefinition Theme { get; set; } = new();
|
||||
public List<ScreenDefinition> Screens { get; set; } = new();
|
||||
|
||||
public static ServerUiSync CreateDefault(string serverName = "GsDChat Server", string motd = "Welcome to GsDChat!")
|
||||
public static ServerUiSync CreateDefault(
|
||||
string serverName = "GsDChat Server",
|
||||
string motd = "Welcome to GsDChat!",
|
||||
bool allowDmE2ee = true,
|
||||
int maxGroupChatUsers = 10)
|
||||
{
|
||||
return new ServerUiSync
|
||||
{
|
||||
ServerName = serverName,
|
||||
Motd = motd,
|
||||
AllowDmE2ee = allowDmE2ee,
|
||||
MaxGroupChatUsers = maxGroupChatUsers,
|
||||
Theme = new ThemeDefinition(),
|
||||
Screens = new List<ScreenDefinition>
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue