Разделение

This commit is contained in:
Халимов Рустам
2026-03-30 15:35:28 +03:00
parent 465e84e686
commit 09e5cbaa76
57 changed files with 631 additions and 233 deletions
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Knot.Contracts.Auth.Abstractions;
public interface IUserQueryService
{
Task<List<UserInfo>> GetAllUsersAsync(CancellationToken cancellationToken);
Task<List<UserInfo>> SearchUsersAsync(string query, CancellationToken cancellationToken);
}
public record UserInfo(Guid Id, string? Avatar, string? UserName, string? DisplayName, DateTime CreatedAt, string? PhoneNumber, string? Email);
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Knot.Contracts.Auth.Domain;
using Microsoft.EntityFrameworkCore;
namespace Knot.Contracts.Auth.Application.Abstractions;
@@ -1,6 +0,0 @@
using Knot.Contracts.Auth.Domain;
using MediatR;
namespace Knot.Contracts.Auth.Application.Users.GetMe;
public record GetMeQuery() : IRequest<UserContract>;
@@ -1,10 +0,0 @@
using Knot.Contracts.Auth.Application.Auth.DTOs;
using Knot.Shared.Kernel;
using MediatR;
namespace Knot.Contracts.Auth.Application.Users.Login;
public record LoginUserCommand(
string Username,
string Password
) : IRequest<Result<AuthResponseDto>>;
@@ -1,14 +0,0 @@
using Knot.Contracts.Auth.Application.Auth.DTOs;
using Knot.Contracts.Auth.Domain;
using Knot.Shared.Kernel;
using MediatR;
namespace Knot.Contracts.Auth.Application.Users.Register;
public record RegisterUserCommand(
string Username,
string Password,
string DisplayName,
string? Email,
string? Bio
) : IRequest<Result<AuthResponseDto>>;
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Knot.Contracts.Cleanup.Abstractions;
public interface ICleanupService
{
Task<CleanupData> GetCleanupDataAsync(CancellationToken cancellationToken);
Task CleanOrphanMessagesAsync(List<Guid> messageIds, CancellationToken cancellationToken);
Task CleanOrphanFilesAsync(List<string> fileIds, CancellationToken cancellationToken);
}
public record CleanupData(
List<ChatCleanupInfo> Chats,
List<MessageCleanupInfo> Messages,
List<StoryCleanupInfo> Stories,
List<UserCleanupInfo> Users,
List<FileCleanupInfo> Files);
public record ChatCleanupInfo(Guid Id, string? Avatar);
public record MessageCleanupInfo(Guid Id, Guid ChatId, bool IsDeleted, string? MediaUrl);
public record StoryCleanupInfo(Guid Id, string? MediaUrl);
public record UserCleanupInfo(Guid Id, string? Avatar);
public record FileCleanupInfo(string FileId);
@@ -0,0 +1,10 @@
<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" />
</ItemGroup>
</Project>
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Knot.Contracts.Conversations.Abstractions;
public interface IChatQueryService
{
Task<List<ChatInfo>> GetAllChatsAsync(CancellationToken cancellationToken);
}
public interface IUserDeleterService
{
Task DeleteUserAsync(Guid userId, CancellationToken cancellationToken);
}
public record ChatInfo(Guid Id, string? Avatar);
@@ -0,0 +1,6 @@
namespace Knot.Contracts.Conversations.Abstractions;
public interface IUserStatusService
{
bool IsUserOnline(string userId);
}
@@ -0,0 +1,24 @@
using Microsoft.AspNetCore.SignalR;
namespace Knot.Contracts.Conversations.Application.Abstractions;
public interface IStoryNotificationsClient
{
Task StoryViewed(Guid storyId, Guid userId);
Task StoryReactionAdded(Guid storyId, Guid userId, string reaction);
Task StoryReactionRemoved(Guid storyId, Guid userId);
}
public interface IChatHubClient
{
Task MessageReceived(object message);
Task MessageDeleted(Guid messageId);
Task MessageEdited(Guid messageId, object newContent);
Task ReactionAdded(Guid messageId, string reaction, Guid userId);
Task ReactionRemoved(Guid messageId, string reaction, Guid userId);
Task UserStatusChanged(Guid userId, bool isOnline);
Task ChatUpdated(object chat);
Task ChatDeleted(Guid chatId);
Task UserJoinedChat(Guid chatId, Guid userId);
Task UserLeftChat(Guid chatId, Guid userId);
}
@@ -0,0 +1,20 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Knot.Contracts.Conversations.Application.Abstractions;
using Knot.Shared.Kernel;
namespace Knot.Contracts.Conversations.Infrastructure.Persistence;
public interface IChatsDbContext : IChatsUnitOfWork
{
IQueryable<Chat> Chats { get; }
}
public class Chat : AggregateRoot<Guid>
{
public Chat() : base(Guid.NewGuid()) { }
public string? Avatar { get; set; }
}
@@ -11,6 +11,10 @@
<ProjectReference Include="..\Messaging\Knot.Contracts.Messaging.csproj" />
</ItemGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MediatR" Version="12.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.4" />
@@ -0,0 +1,6 @@
namespace Knot.Contracts.Klipy.Abstractions;
public interface IKlipyClient
{
Task<bool> TestConnectionAsync(CancellationToken cancellationToken = default);
}
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Knot.Contracts.Messaging.Abstractions;
public interface IMessageQueryService
{
Task<List<MessageInfo>> GetAllMessagesAsync(CancellationToken cancellationToken);
Task DeleteMessagesAsync(List<Guid> messageIds, CancellationToken cancellationToken);
}
public record MessageInfo(Guid Id, Guid ChatId, bool IsDeleted, string? MediaUrl);
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Knot.Contracts.Messaging.Abstractions;
public interface IUserStatsService
{
Task<Dictionary<Guid, UserStats>> GetStatsForUsersAsync(List<Guid> userIds, CancellationToken cancellationToken = default);
}
public record UserStats(int MessageCount, long StorageSize);
@@ -18,4 +18,5 @@ public interface IMessageRepository
Task DeleteChatMessagesAsync(Guid chatId, CancellationToken cancellationToken);
Task DeleteUserMessagesAsync(Guid userId, CancellationToken cancellationToken);
Task RemoveAsync(Guid id, CancellationToken cancellationToken);
Task DeleteAsync(Message message, CancellationToken cancellationToken);
}
@@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Knot.Contracts.Messaging.Application.Abstractions;
public record UserStats(int MessageCount, long StorageSize);
public interface IUserStatsService
{
Task<Dictionary<Guid, UserStats>> GetStatsForUsersAsync(IEnumerable<Guid> userIds, CancellationToken ct = default);
Task<long> GetTotalStorageSizeAsync(CancellationToken ct = default);
Task<int> GetCountOrphanedMessagesAsync(HashSet<Guid> activeChatIds, CancellationToken ct = default);
Task<long> GetOrphanedMediaSizeAsync(HashSet<string> validFileIds, CancellationToken ct = default);
}
@@ -0,0 +1,26 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Knot.Contracts.Messaging.Infrastructure.Persistence;
public interface IMongoMessageCollection
{
Task<List<Message>> GetAllAsync(CancellationToken cancellationToken);
Task<List<Message>> GetOrphanedMessagesAsync(HashSet<Guid> activeChatIds, CancellationToken cancellationToken);
Task DeleteManyAsync(List<Guid> messageIds, CancellationToken cancellationToken);
}
public class Message
{
public Guid Id { get; set; }
public Guid ChatId { get; set; }
public bool IsDeleted { get; set; }
public string? MediaUrl { get; set; }
public List<Media>? Media { get; set; }
}
public class Media
{
public string Url { get; set; } = string.Empty;
}
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Knot.Contracts.Relations.Domain;
namespace Knot.Contracts.Relations.Application.Abstractions;
public interface IFriendshipRepository
{
Task<List<Friendship>> GetAcceptedFriendshipsAsync(Guid userId, CancellationToken ct = default);
}
@@ -0,0 +1,11 @@
namespace Knot.Contracts.Relations.Domain;
using System;
public record Friendship(
Guid Id,
Guid UserId,
Guid FriendId,
FriendshipStatus Status,
DateTime CreatedAt
);
@@ -0,0 +1,8 @@
namespace Knot.Contracts.Relations.Domain;
public enum FriendshipStatus
{
Pending,
Accepted,
Declined
}
@@ -0,0 +1,12 @@
namespace Knot.Contracts.Relations.Domain;
using System;
public record UserReplica(
Guid Id,
string Username,
string DisplayName,
string Avatar,
bool IsExternal,
string? Domain
);
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Knot.Contracts.Stories.Abstractions;
public interface IStoryQueryService
{
Task<List<StoryInfo>> GetAllStoriesAsync(CancellationToken cancellationToken);
}
public record StoryInfo(Guid Id, string? MediaUrl);
@@ -13,6 +13,7 @@
<ItemGroup>
<PackageReference Include="MediatR" Version="12.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.4" />
<PackageReference Include="MongoDB.Driver" Version="3.2.0" />
</ItemGroup>
</Project>