mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
I refactored Govor.Console to use the command pattern. Here's what I did:
- I implemented a command-based architecture for Govor.Console. - Each of your actions (e.g., login, send friend request, list friends) is now encapsulated in its own command class inheriting from BaseCommand. - I integrated friend-related functionalities (search, list, send/accept/reject request, block/unblock) using a mix of SignalR Hub and REST API calls. - I included admin functionalities for managing friendships (list all, list user's, remove). - I added a /help (-h) command to display available commands and their usage. - I refactored Program.cs to handle command parsing and execution. - I updated FriendsClient.cs, removing methods now handled directly by commands via SignalR. - I added SignalR event handlers for real-time notifications (friend requests, accepts, etc.).
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using System.Net.Http.Json;
|
||||
using Govor.Contracts.DTOs;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks; // Added for Task
|
||||
|
||||
namespace Govor.ConsoleClient
|
||||
{
|
||||
@@ -20,11 +23,12 @@ namespace Govor.ConsoleClient
|
||||
return await response.Content.ReadFromJsonAsync<List<UserDto>>() ?? new List<UserDto>();
|
||||
}
|
||||
|
||||
public async Task SendFriendRequestAsync(Guid targetUserId)
|
||||
{
|
||||
var response = await _client.PostAsync($"api/friends/request?targetUserId={targetUserId}", null);
|
||||
response.EnsureSuccessStatusCode();
|
||||
}
|
||||
// SendFriendRequestAsync was removed as the SendFriendRequestCommand now uses SignalR directly.
|
||||
// public async Task SendFriendRequestAsync(Guid targetUserId)
|
||||
// {
|
||||
// var response = await _client.PostAsync($"api/friends/request?targetUserId={targetUserId}", null);
|
||||
// response.EnsureSuccessStatusCode();
|
||||
// }
|
||||
|
||||
public async Task<List<FriendshipDto>> GetIncomingRequestsAsync()
|
||||
{
|
||||
@@ -34,11 +38,12 @@ namespace Govor.ConsoleClient
|
||||
return await response.Content.ReadFromJsonAsync<List<FriendshipDto>>() ?? new List<FriendshipDto>();
|
||||
}
|
||||
|
||||
public async Task AcceptFriendRequestAsync(Guid requesterId)
|
||||
{
|
||||
var response = await _client.PostAsync($"/api/friends/accept?friendshipId={requesterId}", null);
|
||||
response.EnsureSuccessStatusCode();
|
||||
}
|
||||
// AcceptFriendRequestAsync was removed as the AcceptFriendRequestCommand now uses SignalR directly.
|
||||
// public async Task AcceptFriendRequestAsync(Guid friendshipId) // Parameter was requesterId, should be friendshipId
|
||||
// {
|
||||
// var response = await _client.PostAsync($"/api/friends/accept?friendshipId={friendshipId}", null);
|
||||
// response.EnsureSuccessStatusCode();
|
||||
// }
|
||||
|
||||
public async Task<List<UserDto>> GetFriendsAsync()
|
||||
{
|
||||
@@ -49,4 +54,4 @@ namespace Govor.ConsoleClient
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user