mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
rework and starts for new friends system
This commit is contained in:
@@ -17,10 +17,11 @@ public class ChatsHub : Hub
|
||||
private readonly IMessageService _messageService;
|
||||
private readonly IUserGroupsService _userService;
|
||||
|
||||
public ChatsHub(ILogger<ChatsHub> logger, IMessageService messageService)
|
||||
public ChatsHub(ILogger<ChatsHub> logger, IMessageService messageService, IUserGroupsService userService)
|
||||
{
|
||||
_logger = logger;
|
||||
_messageService = messageService;
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
public override async Task OnConnectedAsync()
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using Govor.Application.Interfaces.Friends;
|
||||
using Govor.Application.Interfaces.Infrastructure.Extensions;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace Govor.API.Hubs;
|
||||
|
||||
public class FriendsHub : Hub
|
||||
{
|
||||
private readonly IFriendRequestService _friendRequestService;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public FriendsHub(IFriendRequestService friendRequestService, ICurrentUserService currentUserService)
|
||||
{
|
||||
_friendRequestService = friendRequestService;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
|
||||
public async Task SendRequest(Guid targetUserId)
|
||||
{
|
||||
var userId = _currentUserService.GetCurrentUserId();
|
||||
await _friendRequestService.SendFriendRequestAsync(userId, targetUserId);
|
||||
await Clients.User(targetUserId.ToString()).SendAsync("FriendRequestReceived", userId);
|
||||
}
|
||||
|
||||
public async Task AcceptRequest(Guid friendshipId)
|
||||
{
|
||||
var userId = _currentUserService.GetCurrentUserId();
|
||||
await _friendRequestService.AcceptFriendRequestAsync(friendshipId, userId);
|
||||
await Clients.User(userId.ToString()).SendAsync("FriendRequestAccepted", friendshipId);
|
||||
}
|
||||
|
||||
public async Task RejectRequest(Guid friendshipId)
|
||||
{
|
||||
var userId = _currentUserService.GetCurrentUserId();
|
||||
await _friendRequestService.RejectFriendRequestAsync(friendshipId, userId);
|
||||
await Clients.User(userId.ToString()).SendAsync("FriendRequestRejected", friendshipId);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace Govor.API.Hubs;
|
||||
|
||||
public class UsersHub : Hub
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user