Stop all bot for a user
This commit is contained in:
@@ -195,6 +195,43 @@ public class BotController : BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops all active bots for the connected user.
|
||||
/// </summary>
|
||||
/// <returns>A boolean indicating the result of the stop all operation.</returns>
|
||||
[HttpGet]
|
||||
[Route("StopAll")]
|
||||
public async Task<ActionResult<bool>> StopAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = await GetUser();
|
||||
if (user == null)
|
||||
{
|
||||
return Unauthorized("User not found");
|
||||
}
|
||||
|
||||
var result = await _mediator.Send(new StopAllUserBotsCommand(user));
|
||||
|
||||
if (result)
|
||||
{
|
||||
await NotifyBotSubscriberAsync();
|
||||
_logger.LogInformation($"All bots stopped successfully for user {user.Name}");
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning($"Failed to stop all bots for user {user.Name}");
|
||||
}
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error stopping all bots");
|
||||
return StatusCode(500, $"Error stopping all bots: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a bot specified by name.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user