Refactor message loading API and add message query support

Reworked message loading endpoints and services to support flexible message querying with 'before' and 'after' parameters via a new MessageQuery contract. Updated controller actions, service interfaces, and implementations to use the new query model, and improved error handling. Added integration tests for ChatLoadController and introduced IUserPresenceService interface. Minor fixes and help text improvements in console client commands.
This commit is contained in:
Artemy
2025-07-23 13:06:34 +07:00
parent 1fc13000b1
commit b24649e53a
10 changed files with 300 additions and 81 deletions
@@ -13,6 +13,7 @@ public class OnlinePingingController : Controller
{
private readonly ILogger<OnlinePingingController> _logger;
private readonly IPingHandlerService _ping;
private readonly IUserPresenceService _presenceService;
private readonly ICurrentUserService _currentUserService;
public OnlinePingingController(ILogger<OnlinePingingController> logger,
@@ -51,13 +52,21 @@ public class OnlinePingingController : Controller
catch (Exception e)
{
_logger.LogError(e, e.Message);
return StatusCode(500, new { error = "Failed to send friend request." });
return StatusCode(500, "Failed to ping.");
}
}
[HttpGet("is-online")]
public async Task<IActionResult> IsOnline(Guid userId)
[HttpGet("status/{userId}")]
public IActionResult GetStatus(Guid userId)
{
return BadRequest();
try
{
return Ok(_presenceService.WhenUserWasOnline(userId));
}
catch (Exception e)
{
_logger.LogError(e, e.Message);
return StatusCode(500, "Internal server error.");
}
}
}