feat: enhance profile editing with avatar support and UI adjustments

- Added AvatarPath to ProfileEditResult for user profile updates.
- Updated ProfileEditDialog to include avatar selection with a browse button.
- Increased dialog height to accommodate new avatar input fields.
- Implemented avatar file path handling in the profile edit dialog.

feat: introduce moderation features and user roles

- Added ServerRole enum to define user roles (Member, Mod, Admin, Owner).
- Extended User model to include role, mute, and ban status.
- Created ModerationController for user role assignment, kicking, banning, and muting.
- Implemented methods in IChatBroadcaster and SignalRBroadcaster for user moderation actions.
- Updated database schema with new columns for user roles and moderation states.

fix: ensure muted users cannot send messages

- Added mute status checks in ChatService to prevent message sending for muted users.
- Updated user presence and status handling to reflect role changes and moderation actions.

chore: update constants for ASCII art rendering

- Introduced AsciiArtHeightHalfBlock constant for improved ASCII art rendering.
This commit is contained in:
HueByte
2026-02-19 17:47:10 +01:00
parent 257ac34224
commit b4c3ebd254
28 changed files with 1457 additions and 73 deletions
@@ -10,4 +10,5 @@ public static class HubConstants
public const int MaxAvatarSizeBytes = 2 * 1024 * 1024; // 2 MB
public const int AsciiArtWidth = 80;
public const int AsciiArtHeight = 40;
public const int AsciiArtHeightHalfBlock = 80;
}
@@ -9,5 +9,9 @@ public interface IChatBroadcaster
Task SendUserLeftAsync(string channelName, string username);
Task SendChannelUpdatedAsync(ChannelDto channel, string? channelName = null);
Task SendUserStatusChangedAsync(List<string> channelNames, UserPresenceDto presence);
Task SendUserKickedAsync(string channelName, string username, string? reason);
Task SendUserBannedAsync(string username, string? reason);
Task SendMessageDeletedAsync(string channelName, Guid messageId);
Task SendChannelNukedAsync(string channelName);
Task SendErrorAsync(string connectionId, string message);
}
@@ -12,5 +12,9 @@ public interface IEchoHubClient
Task UserLeft(string channelName, string username);
Task ChannelUpdated(ChannelDto channel);
Task UserStatusChanged(UserPresenceDto presence);
Task UserKicked(string channelName, string username, string? reason);
Task UserBanned(string username, string? reason);
Task MessageDeleted(string channelName, Guid messageId);
Task ChannelNuked(string channelName);
Task Error(string message);
}
+8
View File
@@ -0,0 +1,8 @@
using EchoHub.Core.Models;
namespace EchoHub.Core.DTOs;
public record AssignRoleRequest(string Username, ServerRole Role);
public record MuteRequest(string? Reason = null, int? DurationMinutes = null);
public record BanRequest(string? Reason = null);
public record KickRequest(string? Reason = null);
+3 -1
View File
@@ -11,6 +11,7 @@ public record UserProfileDto(
string? AvatarAscii,
UserStatus Status,
string? StatusMessage,
ServerRole Role,
DateTimeOffset CreatedAt,
DateTimeOffset LastSeenAt);
@@ -28,6 +29,7 @@ public record UserPresenceDto(
string? DisplayName,
string? NicknameColor,
UserStatus Status,
string? StatusMessage);
string? StatusMessage,
ServerRole Role);
public record AvatarUploadResponse(string AvatarAscii);
+9
View File
@@ -0,0 +1,9 @@
namespace EchoHub.Core.Models;
public enum ServerRole
{
Member = 0,
Mod = 1,
Admin = 2,
Owner = 3
}
+4
View File
@@ -11,6 +11,10 @@ public class User
public string? AvatarAscii { get; set; }
public UserStatus Status { get; set; } = UserStatus.Online;
public string? StatusMessage { get; set; }
public ServerRole Role { get; set; } = ServerRole.Member;
public bool IsMuted { get; set; }
public DateTimeOffset? MutedUntil { get; set; }
public bool IsBanned { get; set; }
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
public DateTimeOffset LastSeenAt { get; set; } = DateTimeOffset.UtcNow;
}