diff --git a/backend/src/Host/Program.cs b/backend/src/Host/Program.cs index e835ddc..b6dc5ca 100644 --- a/backend/src/Host/Program.cs +++ b/backend/src/Host/Program.cs @@ -1,16 +1,30 @@ using Knot.Modules.Messaging; using Knot.Shared.Infrastructure; using Knot.Modules.Auth; +using Knot.Modules.Auth.Presentation.Endpoints; using Knot.Modules.Profiles; +using Knot.Modules.Profiles.Presentation.Endpoints; using Knot.Modules.Settings; +using Knot.Modules.Settings.Presentation.Endpoints; using Knot.Modules.Admin; using Knot.Modules.Conversations; using Knot.Modules.Conversations.Infrastructure.SignalR; +using Knot.Modules.Conversations.Presentation.Endpoints; using Knot.Modules.Auth.Infrastructure.Persistence; using Knot.Modules.Conversations.Infrastructure.Persistence; using Knot.Modules.Storage; using Knot.Modules.Stories; +using Knot.Modules.Stories.Presentation.Endpoints; using Knot.Modules.Klipy; +using Knot.Modules.Federation; +using Knot.Modules.WebRtc; +using Knot.Modules.WebRtc.Presentation.Endpoints; +using Knot.Modules.TelegramImport; +using Knot.Modules.TelegramImport.Presentation.Endpoints; +using Knot.Modules.Relations; +using Knot.Modules.Relations.Presentation.Endpoints; +using Host.Endpoints; +using Knot.Host.Presentation.Endpoints; using Microsoft.EntityFrameworkCore; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Tokens; diff --git a/backend/src/Modules/Auth/Application/Users/GetMe/GetMe.cs b/backend/src/Modules/Auth/Application/Users/GetMe/GetMe.cs index 5a11565..b817485 100644 --- a/backend/src/Modules/Auth/Application/Users/GetMe/GetMe.cs +++ b/backend/src/Modules/Auth/Application/Users/GetMe/GetMe.cs @@ -1,6 +1,6 @@ -using Knot.Shared.Kernel; -using Knot.Contracts.Auth.Domain; using Knot.Contracts.Auth.Application.Auth.DTOs; +using Knot.Contracts.Auth.Application.Auth.DTOs; +using Knot.Shared.Kernel; namespace Knot.Modules.Auth.Application.Users.GetMe; diff --git a/backend/src/Modules/Auth/Application/Users/Login/LoginUserCommandHandler.cs b/backend/src/Modules/Auth/Application/Users/Login/LoginUserCommandHandler.cs index a4bf5d8..fdf0bbb 100644 --- a/backend/src/Modules/Auth/Application/Users/Login/LoginUserCommandHandler.cs +++ b/backend/src/Modules/Auth/Application/Users/Login/LoginUserCommandHandler.cs @@ -1,7 +1,6 @@ using BCrypt.Net; using Knot.Contracts.Auth.Application.Abstractions; using Knot.Contracts.Auth.Application.Auth.DTOs; -using Knot.Contracts.Auth.Domain; using Knot.Shared.Kernel; namespace Knot.Modules.Auth.Application.Users.Login; diff --git a/backend/src/Modules/Auth/Application/Users/Register/RegisterUserCommandHandler.cs b/backend/src/Modules/Auth/Application/Users/Register/RegisterUserCommandHandler.cs index 710d599..e170a09 100644 --- a/backend/src/Modules/Auth/Application/Users/Register/RegisterUserCommandHandler.cs +++ b/backend/src/Modules/Auth/Application/Users/Register/RegisterUserCommandHandler.cs @@ -1,16 +1,16 @@ -using Knot.Contracts.Auth.Domain; +using BCrypt.Net; +using BCrypt.Net; using Knot.Contracts.Auth.Application.Abstractions; using Knot.Contracts.Auth.Application.Auth.DTOs; -using Knot.Modules.Auth.Domain; -using Knot.Shared.Kernel; using Knot.Contracts.Settings.Application.Abstractions; using Knot.Contracts.Settings.Application.DTOs; -using BCrypt.Net; +using Knot.Modules.Auth.Domain; +using Knot.Shared.Kernel; namespace Knot.Modules.Auth.Application.Users.Register; /// -/// . +/// ������� ��� ����������� ������ ������������. /// public sealed record RegisterUserCommand( string Username, @@ -20,7 +20,7 @@ public sealed record RegisterUserCommand( string? Bio) : ICommand; /// -/// . +/// ���������� ������� �����������. /// internal sealed class RegisterUserCommandHandler : ICommandHandler { @@ -48,16 +48,16 @@ internal sealed class RegisterUserCommandHandler : ICommandHandler(AuthErrors.IdentityRegistrationDisabled); } - // 1. username + // 1. �������� ������������ username if (!await _userRepository.IsUsernameUniqueAsync(request.Username, cancellationToken)) { return Result.Failure(AuthErrors.IdentityUsernameNotUnique); } - // 2. + // 2. ����������� ������ string passwordHash = BCrypt.Net.BCrypt.HashPassword(request.Password); - // 3. + // 3. �������� �������� var user = User.Create( request.Username, passwordHash, @@ -65,10 +65,10 @@ internal sealed class RegisterUserCommandHandler : ICommandHandler(sp => sp.GetRequiredService()); services.AddScoped(sp => sp.GetRequiredService()); services.AddScoped(sp => sp.GetRequiredService()); - services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/backend/src/Modules/Auth/Domain/IUserRepository.cs b/backend/src/Modules/Auth/Domain/IUserRepository.cs deleted file mode 100644 index bf25a49..0000000 --- a/backend/src/Modules/Auth/Domain/IUserRepository.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Knot.Modules.Auth.Domain; - -namespace Knot.Modules.Auth.Domain; - -/// -/// Интерфейс репозитория для работы с пользователями. -/// -public interface IUserRepository -{ - Task GetByIdAsync(Guid id, CancellationToken cancellationToken = default); - Task> GetByIdsAsync(IEnumerable ids, CancellationToken cancellationToken = default); - Task GetByUsernameAsync(string username, CancellationToken cancellationToken = default); - Task IsUsernameUniqueAsync(string username, CancellationToken cancellationToken = default); - Task> SearchUsersAsync(string query, CancellationToken cancellationToken = default); - void Add(User user); - void Update(User user); - void Remove(User user); -} - diff --git a/backend/src/Modules/Auth/GlobalUsings.cs b/backend/src/Modules/Auth/GlobalUsings.cs new file mode 100644 index 0000000..832e4f0 --- /dev/null +++ b/backend/src/Modules/Auth/GlobalUsings.cs @@ -0,0 +1,4 @@ +// Глобальные алиасы для модуля Auth +// Используем контракты вместо дублирующихся интерфейсов из модуля +global using AuthErrors = Knot.Contracts.Auth.Application.Auth.DTOs.AuthErrors; +global using IUserRepository = Knot.Contracts.Auth.Domain.IUserRepository; diff --git a/backend/src/Modules/Auth/Infrastructure/Services/UserDisplayNameProvider.cs b/backend/src/Modules/Auth/Infrastructure/Services/UserDisplayNameProvider.cs index 6af93cc..6208c61 100644 --- a/backend/src/Modules/Auth/Infrastructure/Services/UserDisplayNameProvider.cs +++ b/backend/src/Modules/Auth/Infrastructure/Services/UserDisplayNameProvider.cs @@ -1,4 +1,3 @@ -using Knot.Contracts.Auth.Domain; using Knot.Shared.Kernel; namespace Knot.Modules.Auth.Infrastructure.Services; diff --git a/backend/src/Modules/Profiles/DependencyInjection.cs b/backend/src/Modules/Profiles/DependencyInjection.cs index 10164b3..e6241ea 100644 --- a/backend/src/Modules/Profiles/DependencyInjection.cs +++ b/backend/src/Modules/Profiles/DependencyInjection.cs @@ -10,15 +10,15 @@ public static class DependencyInjection { public static IServiceCollection AddProfilesModule(this IServiceCollection services, IConfiguration configuration) { - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); // MongoDB Registration - var mongoConnection = configuration.GetConnectionString("MongoConnection") - ?? configuration["MONGO_URL"] + var mongoConnection = configuration.GetConnectionString("MongoConnection") + ?? configuration["MONGO_URL"] ?? "mongodb://mongo:27017"; - + var mongoClient = new MongoClient(mongoConnection); var databaseName = new MongoUrl(mongoConnection).DatabaseName ?? "knot_messager"; var database = mongoClient.GetDatabase(databaseName); diff --git a/backend/src/Modules/Profiles/Domain/IAvatarStorageService.cs b/backend/src/Modules/Profiles/Domain/IAvatarStorageService.cs deleted file mode 100644 index 96f5192..0000000 --- a/backend/src/Modules/Profiles/Domain/IAvatarStorageService.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.IO; -using System.Threading; -using System.Threading.Tasks; - -namespace Knot.Modules.Profiles.Domain; - -public interface IAvatarStorageService -{ - Task UploadAsync(Stream content, string fileName, string contentType, CancellationToken ct = default); - Task DeleteAsync(string fileId, CancellationToken ct = default); -} diff --git a/backend/src/Modules/Profiles/Domain/IProfileRepository.cs b/backend/src/Modules/Profiles/Domain/IProfileRepository.cs deleted file mode 100644 index 74f365a..0000000 --- a/backend/src/Modules/Profiles/Domain/IProfileRepository.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace Knot.Modules.Profiles.Domain; - -public interface IProfileRepository -{ - Task GetByIdAsync(Guid id, CancellationToken ct = default); - Task GetByUsernameAsync(string username, CancellationToken ct = default); - Task AddAsync(ProfileDocument profile, CancellationToken ct = default); - Task UpdateAsync(ProfileDocument profile, CancellationToken ct = default); - Task> SearchAsync(string query, CancellationToken ct = default); -} diff --git a/backend/src/Modules/Profiles/Domain/IProfilesUnitOfWork.cs b/backend/src/Modules/Profiles/Domain/IProfilesUnitOfWork.cs deleted file mode 100644 index b18ed41..0000000 --- a/backend/src/Modules/Profiles/Domain/IProfilesUnitOfWork.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; - -namespace Knot.Modules.Profiles.Domain; - -public interface IProfilesUnitOfWork -{ - Task SaveChangesAsync(CancellationToken ct = default); -} diff --git a/backend/src/Modules/Profiles/Domain/ProfilesErrors.cs b/backend/src/Modules/Profiles/Domain/ProfilesErrors.cs deleted file mode 100644 index 23bc1be..0000000 --- a/backend/src/Modules/Profiles/Domain/ProfilesErrors.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Knot.Modules.Profiles.Domain; -using Knot.Shared.Kernel; -public static class ProfilesErrors -{ - public static readonly Error ProfileNotFound = new("Profile.NotFound", "Profile not found"); -} -public static class IdentityErrors -{ - public static readonly Error UserNotFound = new("Profile.NotFound", "Profile not found"); -} diff --git a/backend/src/Modules/Profiles/GlobalUsings.cs b/backend/src/Modules/Profiles/GlobalUsings.cs index ff58cfb..1ac4666 100644 --- a/backend/src/Modules/Profiles/GlobalUsings.cs +++ b/backend/src/Modules/Profiles/GlobalUsings.cs @@ -1,18 +1,32 @@ +global using System; +global using System; +global using System.Collections.Generic; +global using System.Collections.Generic; +global using System.IO; +global using System.IO; +global using System.Linq; +global using System.Linq; +global using System.Threading; +global using System.Threading; +global using System.Threading.Tasks; +global using System.Threading.Tasks; +global using Knot.Modules.Profiles.Domain; +global using Knot.Modules.Profiles.Domain; +global using Knot.Modules.Profiles.Domain.Events; +global using Knot.Modules.Profiles.Domain.Events; +global using Knot.Modules.Profiles.Infrastructure.Database; +global using Knot.Modules.Profiles.Infrastructure.Database; global using Knot.Shared.Kernel; global using Knot.Shared.Kernel.Events; global using Knot.Shared.Kernel.Storage; -global using Knot.Modules.Profiles.Domain; -global using Knot.Modules.Profiles.Domain.Events; -global using Knot.Modules.Profiles.Infrastructure.Database; +global using MediatR; +global using Microsoft.Extensions.Configuration; +global using Microsoft.Extensions.DependencyInjection; global using MongoDB.Bson; global using MongoDB.Bson.Serialization.Attributes; global using MongoDB.Driver; -global using MediatR; -global using Microsoft.Extensions.DependencyInjection; -global using Microsoft.Extensions.Configuration; -global using System; -global using System.Collections.Generic; -global using System.Threading; -global using System.Threading.Tasks; -global using System.IO; -global using System.Linq; +global using IAvatarStorageService = Knot.Contracts.Profiles.Domain.IAvatarStorageService; +// Алиасы для использования контрактов вместо дублирующихся интерфейсов модуля +global using IProfileRepository = Knot.Contracts.Profiles.Domain.IProfileRepository; +global using IProfilesUnitOfWork = Knot.Contracts.Profiles.Domain.IProfilesUnitOfWork; +global using ProfilesErrors = Knot.Contracts.Profiles.Application.DTOs.ProfilesErrors; diff --git a/backend/src/Modules/Profiles/Infrastructure/Database/ProfileRepository.cs b/backend/src/Modules/Profiles/Infrastructure/Database/ProfileRepository.cs index 2789a00..f9e90eb 100644 --- a/backend/src/Modules/Profiles/Infrastructure/Database/ProfileRepository.cs +++ b/backend/src/Modules/Profiles/Infrastructure/Database/ProfileRepository.cs @@ -3,12 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; -using Knot.Contracts.Profiles.Domain; using Knot.Contracts.Profiles.Application.DTOs; +using Knot.Contracts.Profiles.Domain; using Knot.Modules.Profiles.Domain; using Knot.Modules.Profiles.Infrastructure.Mappings; using Knot.Shared.Kernel; -using ProfilesErrors = Knot.Contracts.Profiles.Application.DTOs.ProfilesErrors; using MongoDB.Bson; using MongoDB.Driver; diff --git a/backend/src/Modules/Stories/Application/Abstractions/IStoriesDbContext.cs b/backend/src/Modules/Stories/Application/Abstractions/IStoriesDbContext.cs index 777b5f5..3656cf1 100644 --- a/backend/src/Modules/Stories/Application/Abstractions/IStoriesDbContext.cs +++ b/backend/src/Modules/Stories/Application/Abstractions/IStoriesDbContext.cs @@ -1,8 +1,9 @@ +using System; using System.Threading; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using Knot.Contracts.Relations.Domain; using Knot.Modules.Stories.Domain; -using Knot.Modules.Relations.Domain; +using Microsoft.EntityFrameworkCore; namespace Knot.Modules.Stories.Application.Abstractions;