mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
b42c7d6de6
- 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.).
51 lines
2.0 KiB
C#
51 lines
2.0 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Net.Http;
|
|
using System.Net.Http.Json;
|
|
using System.Threading.Tasks;
|
|
using Govor.Contracts.DTOs; // Required for FriendshipDto
|
|
|
|
namespace Govor.ConsoleClient.Commands
|
|
{
|
|
public class ListOutgoingRequestsCommand : BaseCommand
|
|
{
|
|
public override async Task ExecuteAsync(string? argument)
|
|
{
|
|
if (!EnsureLoggedIn()) return;
|
|
|
|
try
|
|
{
|
|
// This functionality maps to GET api/friends/responses in FriendsRequestQueryController
|
|
// FriendsClient doesn't have a dedicated method, so we use HttpClientService or direct HttpClient
|
|
var response = await HttpClientService.GetAsync("api/friends/responses");
|
|
response.EnsureSuccessStatusCode();
|
|
|
|
var requests = await response.Content.ReadFromJsonAsync<System.Collections.Generic.List<FriendshipDto>>();
|
|
|
|
if (requests != null && requests.Any())
|
|
{
|
|
Console.WriteLine("Отправленные вами заявки в друзья (ожидают ответа):");
|
|
foreach (var r in requests)
|
|
{
|
|
// If current user is RequesterId, then AddresseeId is the one they sent to.
|
|
Console.WriteLine($"- Запрос ID: {r.Id}. Пользователю ID: {r.AddresseeId}. Статус: {r.Status}.");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("У вас нет отправленных заявок, ожидающих ответа.");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"[Ошибка] {ex.Message}");
|
|
}
|
|
}
|
|
|
|
public override string GetHelp()
|
|
{
|
|
return "/outgoing - Показать список отправленных вами заявок в друзья, ожидающих ответа.";
|
|
}
|
|
}
|
|
}
|