Структура

This commit is contained in:
Халимов Рустам
2026-03-30 00:09:12 +03:00
parent 0209802e9e
commit 89b2eeea6c
124 changed files with 623 additions and 599 deletions
@@ -1,5 +1,5 @@
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Modules.Auth.Contracts.Application.Abstractions;
using Knot.Contracts.Auth.Domain;
using Knot.Contracts.Auth.Application.Abstractions;
using Knot.Shared.Kernel;
using System;
using System.Threading;
@@ -1,5 +1,5 @@
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Modules.Auth.Contracts.Application.Abstractions;
using Knot.Contracts.Auth.Domain;
using Knot.Contracts.Auth.Application.Abstractions;
using Knot.Shared.Kernel;
using System;
using System.Threading;
@@ -1,6 +1,6 @@
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Modules.Auth.Contracts.Application.Abstractions;
using Knot.Modules.Auth.Contracts.Application.Auth.DTOs;
using Knot.Contracts.Auth.Domain;
using Knot.Contracts.Auth.Application.Abstractions;
using Knot.Contracts.Auth.Application.Auth.DTOs;
using Knot.Modules.Admin.Application.Admin.DTOs;
using System;
using System.Threading;
@@ -2,8 +2,8 @@ using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using Knot.Modules.Klipy.Application.Abstractions;
namespace Knot.Modules.Admin.Application.Admin.Commands.TestKlipy;
@@ -4,8 +4,8 @@ using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using System.Security.Cryptography;
namespace Knot.Modules.Admin.Application.Admin.Commands;
@@ -4,8 +4,8 @@ using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
namespace Knot.Modules.Admin.Application.Admin.Queries;
@@ -1,5 +1,5 @@
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Modules.Auth.Contracts.Application.Auth.DTOs;
using Knot.Contracts.Auth.Domain;
using Knot.Contracts.Auth.Application.Auth.DTOs;
using Knot.Modules.Admin.Application.Admin.DTOs;
using Knot.Modules.Messaging.Domain;
using System;
@@ -1,4 +1,4 @@
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Contracts.Auth.Domain;
using Knot.Modules.Admin.Application.Admin.DTOs;
using System;
using System.Collections.Generic;
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
namespace Knot.Modules.Admin.Domain.Events;
@@ -7,10 +7,11 @@
<ItemGroup>
<ProjectReference Include="..\..\Shared\Knot.Shared.Kernel\Knot.Shared.Kernel.csproj" />
<ProjectReference Include="..\..\Shared\Knot.Shared.Infrastructure\Knot.Shared.Infrastructure.csproj" />
<ProjectReference Include="..\..\Contracts\Knot.Modules.Auth.Contracts\Knot.Modules.Auth.Contracts.csproj" />
<ProjectReference Include="..\..\Contracts\Knot.Modules.Profiles.Contracts\Knot.Modules.Profiles.Contracts.csproj" />
<ProjectReference Include="..\..\Contracts\Knot.Modules.Conversations.Contracts\Knot.Modules.Conversations.Contracts.csproj" />
<ProjectReference Include="..\..\Contracts\Knot.Modules.Settings.Contracts\Knot.Modules.Settings.Contracts.csproj" />
<ProjectReference Include="..\..\Contracts\Auth\Knot.Contracts.Auth.csproj" />
<ProjectReference Include="..\..\Contracts\Profiles\Knot.Contracts.Profiles.csproj" />
<ProjectReference Include="..\..\Contracts\Conversations\Knot.Contracts.Conversations.csproj" />
<ProjectReference Include="..\..\Contracts\Settings\Knot.Contracts.Settings.csproj" />
<ProjectReference Include="..\Auth\Knot.Modules.Auth.csproj" />
<ProjectReference Include="..\Conversations\Knot.Modules.Conversations.csproj" />
<ProjectReference Include="..\Stories\Knot.Modules.Stories.csproj" />
<ProjectReference Include="..\Klipy\Knot.Modules.Klipy.csproj" />
@@ -1,8 +1,8 @@
using Carter;
using Knot.Modules.Auth.Contracts.Application.Auth.DTOs;
using Knot.Contracts.Auth.Application.Auth.DTOs;
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using Knot.Modules.Auth.Application.Users.Register;
using MediatR;
using Knot.Modules.Admin.Application.Admin.Queries;
@@ -1,6 +1,6 @@
using Knot.Shared.Kernel;
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Modules.Auth.Contracts.Application.Auth.DTOs;
using Knot.Contracts.Auth.Domain;
using Knot.Contracts.Auth.Application.Auth.DTOs;
namespace Knot.Modules.Auth.Application.Users.GetMe;
@@ -1,6 +1,6 @@
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Modules.Auth.Contracts.Application.Abstractions;
using Knot.Modules.Auth.Contracts.Application.Auth.DTOs;
using Knot.Contracts.Auth.Domain;
using Knot.Contracts.Auth.Application.Abstractions;
using Knot.Contracts.Auth.Application.Auth.DTOs;
using Knot.Shared.Kernel;
using BCrypt.Net;
@@ -1,16 +1,16 @@
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Modules.Auth.Contracts.Application.Abstractions;
using Knot.Modules.Auth.Contracts.Application.Auth.DTOs;
using Knot.Contracts.Auth.Domain;
using Knot.Contracts.Auth.Application.Abstractions;
using Knot.Contracts.Auth.Application.Auth.DTOs;
using Knot.Modules.Auth.Domain;
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using BCrypt.Net;
namespace Knot.Modules.Auth.Application.Users.Register;
/// <summary>
/// Команда для регистрации нового пользователя.
/// Êîìàíäà äëÿ ðåãèñòðàöèè íîâîãî ïîëüçîâàòåëÿ.
/// </summary>
public sealed record RegisterUserCommand(
string Username,
@@ -20,7 +20,7 @@ public sealed record RegisterUserCommand(
string? Bio) : ICommand<AuthResponseDto>;
/// <summary>
/// Обработчик команды регистрации.
/// Îáðàáîò÷èê êîìàíäû ðåãèñòðàöèè.
/// </summary>
internal sealed class RegisterUserCommandHandler : ICommandHandler<RegisterUserCommand, AuthResponseDto>
{
@@ -48,16 +48,16 @@ internal sealed class RegisterUserCommandHandler : ICommandHandler<RegisterUserC
return Result.Failure<AuthResponseDto>(AuthErrors.IdentityRegistrationDisabled);
}
// 1. Проверка уникальности username
// 1. Ïðîâåðêà óíèêàëüíîñòè username
if (!await _userRepository.IsUsernameUniqueAsync(request.Username, cancellationToken))
{
return Result.Failure<AuthResponseDto>(AuthErrors.IdentityUsernameNotUnique);
}
// 2. Хеширование пароля
// 2. Õåøèðîâàíèå ïàðîëÿ
string passwordHash = BCrypt.Net.BCrypt.HashPassword(request.Password);
// 3. Создание сущности
// 3. Ñîçäàíèå ñóùíîñòè
var user = User.Create(
request.Username,
passwordHash,
@@ -65,7 +65,7 @@ internal sealed class RegisterUserCommandHandler : ICommandHandler<RegisterUserC
request.Email,
request.Bio);
// 4. Сохранение - используем метод с Domain User
// 4. Ñîõðàíåíèå - èñïîëüçóåì ìåòîä ñ Domain User
var repoWithDomainUserAdd = _userRepository as Infrastructure.Persistence.UserRepository;
repoWithDomainUserAdd?.Add(user);
@@ -2,9 +2,9 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.EntityFrameworkCore;
using Knot.Modules.Auth.Infrastructure.Persistence;
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Modules.Auth.Contracts.Application.Abstractions;
using Knot.Contracts.Auth.Domain;
using Knot.Contracts.Auth.Domain;
using Knot.Contracts.Auth.Application.Abstractions;
using Knot.Modules.Auth.Infrastructure.Authentication;
using Knot.Shared.Kernel;
+5 -5
View File
@@ -1,11 +1,11 @@
using Knot.Shared.Kernel;
using Knot.Shared.Kernel;
using Knot.Shared.Kernel.Events;
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Contracts.Auth.Domain;
namespace Knot.Modules.Auth.Domain;
/// <summary>
/// Сущность пользователя в контексте идентификации (Identity).
/// Ñóùíîñòü ïîëüçîâàòåëÿ â êîíòåêñòå èäåíòèôèêàöèè (Identity).
/// </summary>
public sealed class User : AggregateRoot<Guid>
{
@@ -44,7 +44,7 @@ public sealed class User : AggregateRoot<Guid>
}
/// <summary>
/// Фабричный метод для создания нового пользователя.
/// Ôàáðè÷íûé ìåòîä äëÿ ñîçäàíèÿ íîâîãî ïîëüçîâàòåëÿ.
/// </summary>
public static User Create(string username, string passwordHash, string displayName, string? email = null, string? bio = null)
{
@@ -54,7 +54,7 @@ public sealed class User : AggregateRoot<Guid>
}
/// <summary>
/// Создает "теневого" пользователя для контакта с другого сервера.
/// Ñîçäàåò "òåíåâîãî" ïîëüçîâàòåëÿ äëÿ êîíòàêòà ñ äðóãîãî ñåðâåðà.
/// </summary>
public static User CreateExternal(Guid id, string username, string displayName, string domain, string? avatar = null)
{
@@ -3,8 +3,9 @@ using System.Security.Claims;
using System.Text;
using Microsoft.Extensions.Configuration;
using Microsoft.IdentityModel.Tokens;
using Knot.Modules.Auth.Contracts.Application.Abstractions;
using Knot.Modules.Auth.Domain;
using Knot.Contracts.Auth.Application.Abstractions;
using Knot.Contracts.Auth.Domain;
using DomainUser = Knot.Modules.Auth.Domain.User;
namespace Knot.Modules.Auth.Infrastructure.Authentication;
@@ -75,7 +76,7 @@ internal sealed class JwtTokenProvider : IJwtTokenProvider
return new JwtSecurityTokenHandler().WriteToken(token);
}
public string Generate(User user)
public string Generate(UserContract user)
{
return Generate(user.Id, user.Username, user.DisplayName, user.Avatar);
}
@@ -1,8 +1,8 @@
using MediatR;
using MediatR;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Knot.Modules.Auth.Contracts.Application.Abstractions;
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Contracts.Auth.Application.Abstractions;
using Knot.Contracts.Auth.Domain;
using Knot.Shared.Kernel;
using Knot.Shared.Kernel.Security;
using DomainUser = Knot.Modules.Auth.Domain.User;
@@ -1,5 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Knot.Modules.Auth.Contracts.Domain;
using Microsoft.EntityFrameworkCore;
using Knot.Contracts.Auth.Domain;
using Knot.Modules.Auth.Domain;
namespace Knot.Modules.Auth.Infrastructure.Persistence;
@@ -1,6 +1,6 @@
using Knot.Shared.Kernel;
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Contracts.Auth.Domain;
using Knot.Contracts.Auth.Domain;
namespace Knot.Modules.Auth.Infrastructure.Services;
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
@@ -8,9 +8,9 @@
<ItemGroup>
<ProjectReference Include="..\..\Shared\Knot.Shared.Kernel\Knot.Shared.Kernel.csproj" />
<ProjectReference Include="..\..\Contracts\Knot.Modules.Auth.Contracts\Knot.Modules.Auth.Contracts.csproj" />
<ProjectReference Include="..\..\Contracts\Knot.Modules.Profiles.Contracts\Knot.Modules.Profiles.Contracts.csproj" />
<ProjectReference Include="..\..\Contracts\Knot.Modules.Settings.Contracts\Knot.Modules.Settings.Contracts.csproj" />
<ProjectReference Include="..\..\Contracts\Auth\Knot.Contracts.Auth.csproj" />
<ProjectReference Include="..\..\Contracts\Profiles\Knot.Contracts.Profiles.csproj" />
<ProjectReference Include="..\..\Contracts\Settings\Knot.Contracts.Settings.csproj" />
</ItemGroup>
<ItemGroup>
@@ -33,6 +33,3 @@
</ItemGroup>
</Project>
@@ -26,7 +26,7 @@ namespace Knot.Modules.Auth.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Knot.Modules.Auth.Contracts.Domain.User", b =>
modelBuilder.Entity("Knot.Contracts.Auth.Domain.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -27,7 +27,7 @@ namespace Knot.Modules.Auth.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Knot.Modules.Auth.Contracts.Domain.User", b =>
modelBuilder.Entity("Knot.Contracts.Auth.Domain.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -26,7 +26,7 @@ namespace Knot.Modules.Auth.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Knot.Modules.Auth.Contracts.Domain.User", b =>
modelBuilder.Entity("Knot.Contracts.Auth.Domain.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -23,7 +23,7 @@ namespace Knot.Modules.Auth.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Knot.Modules.Auth.Contracts.Domain.User", b =>
modelBuilder.Entity("Knot.Contracts.Auth.Domain.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -1,6 +1,6 @@
using Knot.Modules.Conversations.Domain;
using Knot.Modules.Conversations.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Shared.Kernel;
using MediatR;
@@ -2,7 +2,7 @@ using Knot.Modules.Messaging.Application.Abstractions;
using Knot.Modules.Messaging.Domain;
using Knot.Modules.Conversations.Domain;
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Modules.Conversations.Application.Abstractions;
namespace Knot.Modules.Conversations.Application.Messages.Send;
@@ -6,8 +6,8 @@ using System.Threading.Tasks;
using MediatR;
using Knot.Shared.Kernel;
using Knot.Shared.Kernel.Storage;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using Knot.Modules.Conversations.Application.DTOs;
namespace Knot.Modules.Conversations.Application.Messages.UploadFile;
@@ -1,5 +1,5 @@
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Modules.Auth.Contracts.Application.Abstractions;
using Knot.Contracts.Auth.Domain;
using Knot.Contracts.Auth.Application.Abstractions;
using Knot.Modules.Conversations.Domain;
using Knot.Modules.Messaging.Domain;
using Knot.Shared.Kernel;
@@ -1,8 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Shared\Knot.Shared.Kernel\Knot.Shared.Kernel.csproj" />
<ProjectReference Include="..\..\Contracts\Knot.Modules.Settings.Contracts\Knot.Modules.Settings.Contracts.csproj" />
<ProjectReference Include="..\..\Shared\Knot.Shared.Infrastructure\Knot.Shared.Infrastructure.csproj" />
<ProjectReference Include="..\..\Contracts\Settings\Knot.Contracts.Settings.csproj" />
<ProjectReference Include="..\Messaging\Knot.Modules.Messaging.csproj" />
<ProjectReference Include="..\Auth\Knot.Modules.Auth.csproj" />
</ItemGroup>
@@ -30,10 +37,4 @@
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
@@ -2,8 +2,8 @@ using Knot.Shared.Kernel.Constants;
using System.Security.Cryptography;
using MediatR;
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
namespace Host.Application.Federation.Commands;
@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
@@ -8,11 +8,11 @@ using System.Threading.Tasks;
using MediatR;
using Knot.Modules.Federation.Application.Abstractions;
using Knot.Shared.Kernel;
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Contracts.Auth.Domain;
using Knot.Modules.Messaging.Application.Abstractions;
using Knot.Modules.Messaging.Domain;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using Knot.Shared.Kernel.Constants;
namespace Host.Application.Federation.Commands;
@@ -52,7 +52,7 @@ internal sealed class InboundFederationCommandHandler : ICommandHandler<InboundF
var packet = request.Packet;
// 1. Проверяем подпись отправителя
// 1. Ïðîâåðÿåì ïîäïèñü îòïðàâèòåëÿ
var senderConfig = settings.Federation.AllowedDomains.FirstOrDefault(d => d.IsEnabled && d.Domain.Equals(packet.SenderDomain, StringComparison.OrdinalIgnoreCase));
if (senderConfig == null || string.IsNullOrEmpty(senderConfig.PublicKey))
return Result.Failure(new Error("Federation.SenderNotAllowed", "Sender domain not in allowlist."));
@@ -67,7 +67,7 @@ internal sealed class InboundFederationCommandHandler : ICommandHandler<InboundF
}
}
// 2. Расшифровываем IV своим Private Key
// 2. Ðàñøèôðîâûâàåì IV ñâîèì Private Key
byte[] aesKey;
byte[] aesIv;
using (var rsaDecrypt = RSA.Create())
@@ -82,7 +82,7 @@ internal sealed class InboundFederationCommandHandler : ICommandHandler<InboundF
Buffer.BlockCopy(decryptedKeys, 32, aesIv, 0, 16);
}
// 3. Расшифровываем само сообщение (AES-256)
// 3. Ðàñøèôðîâûâàåì ñàìî ñîîáùåíèå (AES-256)
string plainText;
using (var aes = Aes.Create())
{
@@ -96,7 +96,7 @@ internal sealed class InboundFederationCommandHandler : ICommandHandler<InboundF
}
}
// 4. Логика обработки типов сообщений
// 4. Ëîãèêà îáðàáîòêè òèïîâ ñîîáùåíèé
if (packet.Metadata.MessageType == "sync_capabilities")
{
var capabilities = JsonSerializer.Deserialize<RemoteCapabilities>(plainText);
@@ -119,7 +119,7 @@ internal sealed class InboundFederationCommandHandler : ICommandHandler<InboundF
user.IsOnline = isOnline;
await _userRepository.UpdateAsync(user, cancellationToken);
// Уведомляем локальных пользователей через SignalR
// Óâåäîìëÿåì ëîêàëüíûõ ïîëüçîâàòåëåé ÷åðåç SignalR
await _notifier.NotifyNewMessageAsync(Guid.Empty, new { type = "presence_update", userId = user.Id, isOnline = user.IsOnline }, cancellationToken);
}
return Result.Success();
@@ -183,7 +183,7 @@ internal sealed class InboundFederationCommandHandler : ICommandHandler<InboundF
if (packet.Metadata.MessageType == "poll" && !settings.Messages.AllowPolls)
return Result.Failure(new Error("Federation.PollsDisabled", "We do not accept polls."));
// 5. Сохранение в базу сообщений (MongoDB)
// 5. Ñîõðàíåíèå â áàçó ñîîáùåíèé (MongoDB)
var message = new TextMessage(
Guid.NewGuid(),
packet.Metadata.ChatId,
@@ -197,7 +197,7 @@ internal sealed class InboundFederationCommandHandler : ICommandHandler<InboundF
_messageRepository.Add(message);
// 6. Уведомление пользователя через SignalR
// 6. Óâåäîìëåíèå ïîëüçîâàòåëÿ ÷åðåç SignalR
await _notifier.NotifyNewMessageAsync(packet.Metadata.ChatId, message, cancellationToken);
return Result.Success();
@@ -3,9 +3,9 @@ using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Knot.Shared.Kernel;
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Auth.Domain;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using System.Linq;
namespace Host.Application.Federation.Commands;
@@ -7,9 +7,9 @@ using Knot.Modules.Messaging.Domain;
using Knot.Modules.Federation.Application.Federation.Services;
using Knot.Modules.Conversations.Domain;
using Knot.Modules.Federation.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using Knot.Contracts.Auth.Domain;
namespace Knot.Modules.Federation.Application.Federation.Events;
@@ -7,9 +7,9 @@ using Knot.Modules.Messaging.Domain;
using Knot.Modules.Federation.Application.Federation.Services;
using Knot.Modules.Conversations.Domain;
using Knot.Modules.Federation.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using Knot.Contracts.Auth.Domain;
namespace Knot.Modules.Federation.Application.Federation.Events;
@@ -6,8 +6,8 @@ using MediatR;
using Knot.Modules.Settings.Domain.Events;
using Knot.Modules.Federation.Application.Abstractions;
using Knot.Modules.Federation.Application.Federation.Services;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
namespace Knot.Modules.Federation.Application.Federation.Events;
@@ -1,21 +1,21 @@
using System;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Knot.Modules.Auth.Contracts.Domain;
using Knot.Contracts.Auth.Domain;
using Knot.Modules.Auth.Domain;
using Knot.Modules.Conversations.Domain;
using Knot.Modules.Federation.Application.Abstractions;
using Knot.Modules.Federation.Application.Federation.Services;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
namespace Knot.Modules.Federation.Application.Federation.Events;
/// <summary>
/// Обработчик изменения статуса пользователя.
/// Рассылает новый статус всем серверам, где у пользователя есть чаты.
/// Îáðàáîò÷èê èçìåíåíèÿ ñòàòóñà ïîëüçîâàòåëÿ.
/// Ðàññûëàåò íîâûé ñòàòóñ âñåì ñåðâåðàì, ãäå ó ïîëüçîâàòåëÿ åñòü ÷àòû.
/// </summary>
public sealed class UserStatusChangedDomainEventHandler : INotificationHandler<UserStatusChangedDomainEvent>
{
@@ -44,11 +44,11 @@ public sealed class UserStatusChangedDomainEventHandler : INotificationHandler<U
var settings = await _settingsService.GetSettingsAsync(cancellationToken);
if (!settings.Federation.Enabled) return;
// 1. Находим все чаты пользователя
// 1. Íàõîäèì âñå ÷àòû ïîëüçîâàòåëÿ
var userChats = await _chatRepository.GetUserChatsAsync(notification.UserId, cancellationToken);
if (!userChats.Any()) return;
// 2. Определяем уникальные внешние домены участников этих чатов
// 2. Îïðåäåëÿåì óíèêàëüíûå âíåøíèå äîìåíû ó÷àñòíèêîâ ýòèõ ÷àòîâ
var allMemberIds = userChats.SelectMany(c => c.Members.Select(m => m.UserId)).Distinct().ToList();
var members = await _userRepository.GetByIdsAsync(allMemberIds, cancellationToken);
@@ -60,7 +60,7 @@ public sealed class UserStatusChangedDomainEventHandler : INotificationHandler<U
if (!externalDomains.Any()) return;
// 3. Формируем пакет статуса
// 3. Ôîðìèðóåì ïàêåò ñòàòóñà
var statusData = new {
notification.IsOnline,
notification.LastSeen
@@ -75,7 +75,7 @@ public sealed class UserStatusChangedDomainEventHandler : INotificationHandler<U
DateTime.UtcNow
);
// 4. Рассылка по доменам
// 4. Ðàññûëêà ïî äîìåíàì
foreach (var domain in externalDomains)
{
var packetResult = await _packetService.PreparePacketAsync(payload, metadata, domain, cancellationToken);
@@ -8,8 +8,8 @@ using System.Threading;
using System.Threading.Tasks;
using Knot.Modules.Federation.Application.Abstractions;
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using Knot.Shared.Kernel.Security;
namespace Knot.Modules.Federation.Application.Federation.Services;
@@ -8,8 +8,8 @@ using System.Threading;
using System.Threading.Tasks;
using Knot.Modules.Federation.Application.Abstractions;
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using Knot.Shared.Kernel.Security;
namespace Knot.Modules.Federation.Infrastructure.Services;
@@ -7,11 +7,12 @@
<ItemGroup>
<ProjectReference Include="..\..\Shared\Knot.Shared.Kernel\Knot.Shared.Kernel.csproj" />
<ProjectReference Include="..\..\Shared\Knot.Shared.Infrastructure\Knot.Shared.Infrastructure.csproj" />
<ProjectReference Include="..\..\Contracts\Knot.Modules.Auth.Contracts\Knot.Modules.Auth.Contracts.csproj" />
<ProjectReference Include="..\Conversations\Knot.Modules.Conversations.csproj" />
<ProjectReference Include="..\..\Contracts\Auth\Knot.Contracts.Auth.csproj" />
<ProjectReference Include="..\..\Contracts\Settings\Knot.Contracts.Settings.csproj" />
<ProjectReference Include="..\Auth\Knot.Modules.Auth.csproj" />
<ProjectReference Include="..\Conversations\Knot.Modules.Conversations.csproj" />
<ProjectReference Include="..\Messaging\Knot.Modules.Messaging.csproj" />
<ProjectReference Include="..\Stories\Knot.Modules.Stories.csproj" />
<ProjectReference Include="..\Settings\Knot.Modules.Settings.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Carter" Version="10.0.0" />
@@ -9,8 +9,8 @@ using System;
using Host.Application.Federation.Commands;
using Knot.Modules.Federation.Application.Abstractions;
using Knot.Shared.Kernel.Storage;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
namespace Host.Endpoints;
@@ -1,6 +1,6 @@
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using Knot.Shared.Kernel.Constants;
using Microsoft.Extensions.Caching.Memory;
using System;
@@ -1,6 +1,6 @@
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using Knot.Shared.Kernel.Constants;
using Microsoft.Extensions.Caching.Memory;
using System;
@@ -7,7 +7,7 @@
<ItemGroup>
<ProjectReference Include="..\..\Shared\Knot.Shared.Kernel\Knot.Shared.Kernel.csproj" />
<ProjectReference Include="..\..\Shared\Knot.Shared.Infrastructure\Knot.Shared.Infrastructure.csproj" />
<ProjectReference Include="..\..\Contracts\Knot.Modules.Settings.Contracts\Knot.Modules.Settings.Contracts.csproj" />
<ProjectReference Include="..\..\Contracts\Settings\Knot.Contracts.Settings.csproj" />
<ProjectReference Include="..\Settings\Knot.Modules.Settings.csproj" />
</ItemGroup>
<ItemGroup>
@@ -1,6 +1,6 @@
using Knot.Shared.Kernel;
using Knot.Modules.Profiles.Contracts.Domain;
using Knot.Modules.Profiles.Contracts.Application.DTOs;
using Knot.Contracts.Profiles.Domain;
using Knot.Contracts.Profiles.Application.DTOs;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using System;
@@ -1,6 +1,6 @@
using Knot.Shared.Kernel;
using Knot.Modules.Profiles.Contracts.Domain;
using Knot.Modules.Profiles.Contracts.Application.DTOs;
using Knot.Contracts.Profiles.Domain;
using Knot.Contracts.Profiles.Application.DTOs;
using System;
using System.IO;
using System.Threading;
@@ -1,6 +1,6 @@
using Knot.Shared.Kernel;
using Knot.Modules.Profiles.Contracts.Domain;
using Knot.Modules.Profiles.Contracts.Application.DTOs;
using Knot.Contracts.Profiles.Domain;
using Knot.Contracts.Profiles.Application.DTOs;
using System;
using System.Threading;
using System.Threading.Tasks;
@@ -1,17 +1,17 @@
using MediatR;
using MediatR;
using System.Threading;
using System.Threading.Tasks;
using Knot.Modules.Profiles.Contracts.Domain;
using Knot.Contracts.Profiles.Domain;
using Knot.Modules.Profiles.Domain;
using Knot.Shared.Kernel.Events;
namespace Knot.Modules.Profiles.Application.Profiles.Integration;
/// <summary>
/// Îáðàáîò÷èê ñîáûòèÿ èç ìîäóëÿ Auth.
/// Ñîçäà¸ò ïóñòîé ïðîôèëü ïðè ðåãèñòðàöèè ïîëüçîâàòåëÿ.
/// Обработчик события из модуля Auth.
/// Создаёт пустой профиль при регистрации пользователя.
/// </summary>
internal class UserRegisteredDomainEventHandler : INotificationHandler<UserRegisteredDomainEvent>
public class UserRegisteredDomainEventHandler : INotificationHandler<UserRegisteredDomainEvent>
{
private readonly IProfileRepository _repository;
@@ -26,7 +26,7 @@ internal class UserRegisteredDomainEventHandler : INotificationHandler<UserRegis
if (profile != null)
return;
await _repository.CreateAsync(new Contracts.Application.DTOs.UserProfileDto
await _repository.CreateAsync(new Knot.Contracts.Profiles.Application.DTOs.UserProfileDto
{
UserId = notification.UserId,
Username = notification.Username,
@@ -1,6 +1,6 @@
using Knot.Shared.Kernel;
using Knot.Modules.Profiles.Contracts.Domain;
using Knot.Modules.Profiles.Contracts.Application.DTOs;
using Knot.Contracts.Profiles.Domain;
using Knot.Contracts.Profiles.Application.DTOs;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@@ -1,6 +1,6 @@
using Knot.Shared.Kernel;
using Knot.Modules.Profiles.Contracts.Domain;
using Knot.Modules.Profiles.Contracts.Application.DTOs;
using Knot.Contracts.Profiles.Domain;
using Knot.Contracts.Profiles.Application.DTOs;
using System;
using System.Threading;
using System.Threading.Tasks;
@@ -1,6 +1,6 @@
using Knot.Shared.Kernel;
using Knot.Modules.Profiles.Contracts.Domain;
using Knot.Modules.Profiles.Contracts.Application.DTOs;
using Knot.Contracts.Profiles.Domain;
using Knot.Contracts.Profiles.Application.DTOs;
using System;
using System.Threading;
using System.Threading.Tasks;
@@ -1,4 +1,4 @@
using Knot.Modules.Profiles.Contracts.Domain;
using Knot.Contracts.Profiles.Domain;
using Knot.Modules.Profiles.Infrastructure.Database;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -1,7 +1,7 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Knot.Modules.Profiles.Contracts.Domain;
using Knot.Contracts.Profiles.Domain;
using Knot.Shared.Kernel.Storage;
namespace Knot.Modules.Profiles.Infrastructure.Database;
@@ -3,12 +3,12 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Knot.Modules.Profiles.Contracts.Domain;
using Knot.Modules.Profiles.Contracts.Application.DTOs;
using Knot.Contracts.Profiles.Domain;
using Knot.Contracts.Profiles.Application.DTOs;
using Knot.Modules.Profiles.Domain;
using Knot.Modules.Profiles.Infrastructure.Mappings;
using Knot.Shared.Kernel;
using ProfilesErrors = Knot.Modules.Profiles.Contracts.Application.DTOs.ProfilesErrors;
using ProfilesErrors = Knot.Contracts.Profiles.Application.DTOs.ProfilesErrors;
using MongoDB.Bson;
using MongoDB.Driver;
@@ -1,6 +1,6 @@
using System.Threading;
using System.Threading.Tasks;
using Knot.Modules.Profiles.Contracts.Domain;
using Knot.Contracts.Profiles.Domain;
using Knot.Shared.Kernel;
namespace Knot.Modules.Profiles.Infrastructure.Database;
@@ -1,4 +1,4 @@
using Knot.Modules.Profiles.Contracts.Application.DTOs;
using Knot.Contracts.Profiles.Application.DTOs;
using Knot.Modules.Profiles.Domain;
namespace Knot.Modules.Profiles.Infrastructure.Mappings;
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
@@ -8,6 +8,8 @@
<ItemGroup>
<ProjectReference Include="..\..\Shared\Knot.Shared.Kernel\Knot.Shared.Kernel.csproj" />
<ProjectReference Include="..\..\Shared\Knot.Shared.Infrastructure\Knot.Shared.Infrastructure.csproj" />
<ProjectReference Include="..\..\Contracts\Profiles\Knot.Contracts.Profiles.csproj" />
</ItemGroup>
<ItemGroup>
@@ -19,18 +21,9 @@
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.12" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Shared\Knot.Shared.Kernel\Knot.Shared.Kernel.csproj" />
<ProjectReference Include="..\..\Shared\Knot.Shared.Infrastructure\Knot.Shared.Infrastructure.csproj" />
<ProjectReference Include="..\..\Contracts\Knot.Modules.Profiles.Contracts\Knot.Modules.Profiles.Contracts.csproj" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Knot.Modules.Profiles.UnitTests" />
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
</ItemGroup>
</Project>
@@ -4,8 +4,8 @@ using System.Threading.Tasks;
using MediatR;
using Knot.Shared.Kernel;
using System.Security.Cryptography;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
namespace Knot.Modules.Settings.Application.Settings.Commands;
@@ -2,8 +2,8 @@ using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
namespace Knot.Modules.Settings.Application.Settings.Queries;
@@ -1,6 +1,6 @@
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
@@ -1,6 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Modules.Settings.Infrastructure.Configuration;
namespace Knot.Modules.Settings;
@@ -1,4 +1,4 @@
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.DTOs;
using Knot.Shared.Kernel;
namespace Knot.Modules.Settings.Domain.Events;
@@ -9,8 +9,8 @@ using Microsoft.Extensions.DependencyInjection;
using Knot.Shared.Infrastructure.Persistence;
using Knot.Shared.Infrastructure.Persistence.Entities;
using Knot.Shared.Kernel.Security;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
namespace Knot.Modules.Settings.Infrastructure.Configuration;
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
@@ -7,13 +7,9 @@
<ItemGroup>
<ProjectReference Include="..\..\Shared\Knot.Shared.Kernel\Knot.Shared.Kernel.csproj" />
<ProjectReference Include="..\..\Shared\Knot.Shared.Infrastructure\Knot.Shared.Infrastructure.csproj" />
<ProjectReference Include="..\..\Contracts\Knot.Modules.Settings.Contracts\Knot.Modules.Settings.Contracts.csproj" />
<ProjectReference Include="..\..\Contracts\Settings\Knot.Contracts.Settings.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Carter" Version="10.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.4" />
</ItemGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>
@@ -6,8 +6,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Mvc;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using System.Text;
using System.Security.Cryptography;
@@ -3,8 +3,8 @@ using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using Knot.Modules.Stories.Domain;
@@ -11,8 +11,8 @@ using System.Threading.Tasks;
using AngleSharp.Html.Parser;
using AngleSharp.Dom;
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using MediatR;
namespace Knot.Modules.TelegramImport.Application.TelegramImport;
@@ -1,6 +1,6 @@
using Knot.Shared.Kernel;
using Knot.Modules.Settings.Contracts.Application.Abstractions;
using Knot.Modules.Settings.Contracts.Application.DTOs;
using Knot.Contracts.Settings.Application.Abstractions;
using Knot.Contracts.Settings.Application.DTOs;
using MediatR;
using System.Collections.Generic;
using System.Threading;