mirror of
https://github.com/Stone-Red-Code/EchoHub.git
synced 2026-09-04 09:06:07 +02:00
Refactor and update various components of EchoHub.Server
- Updated launchSettings.json for consistency. - Refactored FileValidationHelper to improve image validation logic. - Enhanced ServerDirectoryService for better connection handling and user count updates. - Improved DatabaseSetup for legacy database handling and seeding default channels. - Refined FirstRunSetup to ensure JWT secret generation. - Removed appsettings.Development.json as it is no longer needed. - Updated EchoHub.Tests project file for consistency. - Added unit tests for FileValidationHelper and PresenceTracker with improved assertions. - Updated ValidationConstantsTests to ensure regex validations are correct. - Cleaned up solution file formatting for better readability.
This commit is contained in:
@@ -1,26 +1,26 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace EchoHub.Core.Constants;
|
||||
|
||||
public static partial class ValidationConstants
|
||||
{
|
||||
public const string UsernamePattern = @"^[a-zA-Z0-9_-]{3,50}$";
|
||||
public const string ChannelNamePattern = @"^[a-zA-Z0-9_-]{2,100}$";
|
||||
public const string HexColorPattern = @"^#[0-9a-fA-F]{6}$";
|
||||
|
||||
public const int MaxPasswordLength = 128;
|
||||
public const int MaxDisplayNameLength = 100;
|
||||
public const int MaxBioLength = 500;
|
||||
public const int MaxStatusMessageLength = 100;
|
||||
public const int MaxChannelTopicLength = 500;
|
||||
public const int MaxHistoryCount = 100;
|
||||
|
||||
[GeneratedRegex(UsernamePattern)]
|
||||
public static partial Regex UsernameRegex();
|
||||
|
||||
[GeneratedRegex(ChannelNamePattern)]
|
||||
public static partial Regex ChannelNameRegex();
|
||||
|
||||
[GeneratedRegex(HexColorPattern)]
|
||||
public static partial Regex HexColorRegex();
|
||||
}
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace EchoHub.Core.Constants;
|
||||
|
||||
public static partial class ValidationConstants
|
||||
{
|
||||
public const string UsernamePattern = @"^[a-zA-Z0-9_-]{3,50}$";
|
||||
public const string ChannelNamePattern = @"^[a-zA-Z0-9_-]{2,100}$";
|
||||
public const string HexColorPattern = @"^#[0-9a-fA-F]{6}$";
|
||||
|
||||
public const int MaxPasswordLength = 128;
|
||||
public const int MaxDisplayNameLength = 100;
|
||||
public const int MaxBioLength = 500;
|
||||
public const int MaxStatusMessageLength = 100;
|
||||
public const int MaxChannelTopicLength = 500;
|
||||
public const int MaxHistoryCount = 100;
|
||||
|
||||
[GeneratedRegex(UsernamePattern)]
|
||||
public static partial Regex UsernameRegex();
|
||||
|
||||
[GeneratedRegex(ChannelNamePattern)]
|
||||
public static partial Regex ChannelNameRegex();
|
||||
|
||||
[GeneratedRegex(HexColorPattern)]
|
||||
public static partial Regex HexColorRegex();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace EchoHub.Core.DTOs;
|
||||
|
||||
public record ErrorResponse(string Error, string? Detail = null);
|
||||
|
||||
public record PaginatedResponse<T>(List<T> Items, int Total, int Offset, int Limit);
|
||||
namespace EchoHub.Core.DTOs;
|
||||
|
||||
public record ErrorResponse(string Error, string? Detail = null);
|
||||
|
||||
public record PaginatedResponse<T>(List<T> Items, int Total, int Offset, int Limit);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
namespace EchoHub.Core.Models;
|
||||
|
||||
public class RefreshToken
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public required string TokenHash { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public DateTimeOffset ExpiresAt { get; set; }
|
||||
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
public DateTimeOffset? RevokedAt { get; set; }
|
||||
|
||||
public bool IsExpired => DateTimeOffset.UtcNow >= ExpiresAt;
|
||||
public bool IsRevoked => RevokedAt is not null;
|
||||
public bool IsActive => !IsExpired && !IsRevoked;
|
||||
|
||||
public User? User { get; set; }
|
||||
}
|
||||
namespace EchoHub.Core.Models;
|
||||
|
||||
public class RefreshToken
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public required string TokenHash { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public DateTimeOffset ExpiresAt { get; set; }
|
||||
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
public DateTimeOffset? RevokedAt { get; set; }
|
||||
|
||||
public bool IsExpired => DateTimeOffset.UtcNow >= ExpiresAt;
|
||||
public bool IsRevoked => RevokedAt is not null;
|
||||
public bool IsActive => !IsExpired && !IsRevoked;
|
||||
|
||||
public User? User { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user