mirror of
https://github.com/Govor-team/Govor.git
synced 2026-11-16 20:56:03 +00:00
29cc51ee0c
Implements message reactions and reaction packs (domain models, services, admin HTTP API, media processing via ImageSharp and limits) and adds reliable push delivery (ChatPushNotification, ChatPushDispatcher, ChatPushWorker, improved ChatNotificationService). Enhances message reading (ReadChat API, unread counts, concurrency-safe receipts) and tightens session security (access-token session validation in JWT, hub filter, SessionAuthorization). Improves SignalR behavior (session groups, reaction/channel events, hub/error mappings). Adds EF migrations, many controller fixes (Forbid handling, password API), tests (Govor.Server.Tests), docs, CI and tooling updates (Dockerfile → .NET 10, GH Actions matrix for sqlite/postgres, Govor.Server.slnx, global.json), and small infra changes (AutoMapper bump, NullPushProvider, storage/token handling).
74 lines
2.1 KiB
C#
74 lines
2.1 KiB
C#
using Govor.Application.Infrastructure.Extensions;
|
|
using Govor.Application.PingHandler;
|
|
using Govor.Application.Users.UserOnlineStatus;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Govor.API.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/online")]
|
|
[Authorize(Roles = "User,Admin")]
|
|
public class OnlinePingingController : Controller
|
|
{
|
|
private readonly ILogger<OnlinePingingController> _logger;
|
|
private readonly IPingHandlerService _ping;
|
|
private readonly IUserPresenceReader _presenceReader;
|
|
private readonly IOnlineUserStore _userOnlineStore;
|
|
private readonly ICurrentUserService _currentUserService;
|
|
|
|
public OnlinePingingController(ILogger<OnlinePingingController> logger,
|
|
IPingHandlerService ping,
|
|
ICurrentUserService currentUserService,
|
|
IUserPresenceReader presenceReader,
|
|
IOnlineUserStore userOnlineStore)
|
|
{
|
|
_logger = logger;
|
|
_ping = ping;
|
|
_currentUserService = currentUserService;
|
|
_presenceReader = presenceReader;
|
|
_userOnlineStore = userOnlineStore;
|
|
}
|
|
|
|
|
|
[HttpPatch("ping")]// api/online/ping
|
|
public async Task<IActionResult> Ping()
|
|
{
|
|
try
|
|
{
|
|
_logger.LogInformation("Ping...");
|
|
|
|
var id = _currentUserService.GetCurrentUserId();
|
|
await _ping.Ping(id);
|
|
|
|
_logger.LogInformation($"Ping from user {id} processed successfully");
|
|
return Ok();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
_logger.LogError(e, e.Message);
|
|
return StatusCode(500, "Failed to ping.");
|
|
}
|
|
}
|
|
|
|
[HttpGet("status/{userId}")]
|
|
public async Task<IActionResult> GetStatus(Guid userId)
|
|
{
|
|
try
|
|
{
|
|
var isOnline = _userOnlineStore.IsOnline(userId);
|
|
var lastSeen = await _presenceReader.GetLastSeenAsync(userId);
|
|
|
|
return Ok(new {
|
|
isOnline,
|
|
lastSeen
|
|
});
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
_logger.LogError(e, e.Message);
|
|
return StatusCode(500, "Internal server error.");
|
|
}
|
|
}
|
|
}
|