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.).
43 lines
1.6 KiB
C#
43 lines
1.6 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Govor.ConsoleClient.Commands
|
|
{
|
|
public class RejectFriendRequestCommand : BaseCommand
|
|
{
|
|
public override async Task ExecuteAsync(string? argument)
|
|
{
|
|
if (!EnsureLoggedIn() || !EnsureHubConnection()) return;
|
|
|
|
Guid friendshipId;
|
|
if (string.IsNullOrWhiteSpace(argument) || !Guid.TryParse(argument, out friendshipId))
|
|
{
|
|
Console.Write("Введите ID заявки, которую хотите отклонить: ");
|
|
var input = Console.ReadLine();
|
|
if (string.IsNullOrWhiteSpace(input) || !Guid.TryParse(input, out friendshipId))
|
|
{
|
|
Console.WriteLine("[Ошибка] Неверный или пустой ID заявки.");
|
|
return;
|
|
}
|
|
}
|
|
|
|
try
|
|
{
|
|
// API uses Hub for this: RejectFriendRequest(Guid friendshipId)
|
|
// Located in Govor.API/Hubs/FriendsHub.cs
|
|
await HubConnection.InvokeAsync("RejectFriendRequest", friendshipId);
|
|
Console.WriteLine("Заявка в друзья отклонена.");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"[Ошибка отклонения заявки] {ex.Message}");
|
|
}
|
|
}
|
|
|
|
public override string GetHelp()
|
|
{
|
|
return "/reject [ID_заявки] - Отклонить входящую заявку в друзья. Если ID не указан, запросит ввод.";
|
|
}
|
|
}
|
|
}
|