mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
Add online pinging and friendship verification features
Introduces OnlinePingingController and related integration/unit tests for user online status updates. Adds PingHandlerService with memory cache throttling, IPingHandlerService interface, and service registration. Implements VerifyFriendship service and interface for friendship validation, with exception handling. Refactors CurrentUserService for improved user ID extraction and testability. Updates ChatsHub to verify friendship before messaging. Cleans up MediaController and optimizes UsersRepository queries by removing unnecessary includes.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Security.Claims;
|
||||
using Govor.Application.Interfaces;
|
||||
using Govor.Contracts.Requests.SignalR;
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Repositories.Users;
|
||||
@@ -13,6 +14,7 @@ namespace Govor.API.Hubs;
|
||||
public class ChatsHub : Hub
|
||||
{
|
||||
private readonly IUsersRepository _usersRepository;
|
||||
private readonly IVerifyFriendship _verifyFriendship;
|
||||
private readonly ILogger<ChatsHub> _logger;
|
||||
|
||||
public ChatsHub(IUsersRepository usersRepository, ILogger<ChatsHub> logger)
|
||||
@@ -60,21 +62,22 @@ public class ChatsHub : Hub
|
||||
|
||||
var senderId = GetUserId();
|
||||
|
||||
// Проверка существования получателя
|
||||
/*try
|
||||
// Проверка существования получателя и установленной дружбы
|
||||
try
|
||||
{
|
||||
await _usersRepository.FindByIdAsync(toUserId);
|
||||
await _usersRepository.FindByIdAsync(request.RecipientId);
|
||||
await _verifyFriendship.VerifyAsync(senderId, request.RecipientId);
|
||||
}
|
||||
catch (NotFoundByKeyException<User> ex)
|
||||
{
|
||||
_logger.LogWarning("Recipient user {ToUserId} not found", toUserId);
|
||||
_logger.LogWarning("Recipient user {ToUserId} not found", request.RecipientId);
|
||||
throw;
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
_logger.LogWarning("Invalid recipient userId received from user {UserId}", GetUserId());
|
||||
throw;
|
||||
}*/
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user