mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
Add username validation and initial friends feature
Introduced a UsernameValidator with Cyrillic and length checks, integrated into AuthService and registration flow. Added InvalidUsernameException and related interface. Updated User model to support friend requests, added FriendsController (stub), and configured Friendship entity in EF Core. Adjusted UserValidator max name length and removed navigation properties from PrivateChat.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using Govor.Core.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Govor.Data.Configurations;
|
||||
|
||||
public class FriendshipConfiguration : IEntityTypeConfiguration<Friendship>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Friendship> builder)
|
||||
{
|
||||
builder.HasKey(f => f.Id);
|
||||
|
||||
builder.HasOne(f => f.Requester)
|
||||
.WithMany(u => u.SentFriendRequests)
|
||||
.HasForeignKey(f => f.RequesterId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
builder.HasOne(f => f.Addressee)
|
||||
.WithMany(u => u.ReceivedFriendRequests)
|
||||
.HasForeignKey(f => f.AddresseeId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
builder.Property(f => f.Status)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ public class GovorDbContext(DbContextOptions<GovorDbContext> options) : DbContex
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfiguration(new FriendshipConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new UserConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new InvitationConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new AdminConfiguration());
|
||||
|
||||
Reference in New Issue
Block a user