Add user online presence tracking and notification

Introduced interfaces and services for tracking user online status, including IOnlineUserStore, IUserNotificationScopeService, and IUserPresenceReader. Added PresenceHub for real-time presence updates via SignalR. Updated OnlinePingingController to use new services and return online status and last seen. Extended UserDto with IsOnline property. Updated dependency injection and privacy settings enum. Removed obsolete IUserPresenceService.
This commit is contained in:
Artemy
2025-07-23 21:07:29 +07:00
parent cbff5857e7
commit 31fdf4cb37
13 changed files with 231 additions and 11 deletions
@@ -1,6 +1,6 @@
using Govor.Application.Interfaces;
using Govor.Application.Interfaces.Infrastructure.Extensions;
using Govor.Core.Repositories.Users;
using Govor.Application.Interfaces.UserOnlineStatus;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -13,7 +13,8 @@ public class OnlinePingingController : Controller
{
private readonly ILogger<OnlinePingingController> _logger;
private readonly IPingHandlerService _ping;
private readonly IUserPresenceService _presenceService;
private readonly IUserPresenceReader _presenceReader;
private readonly IOnlineUserStore _userOnlineStore;
private readonly ICurrentUserService _currentUserService;
public OnlinePingingController(ILogger<OnlinePingingController> logger,
@@ -57,11 +58,17 @@ public class OnlinePingingController : Controller
}
[HttpGet("status/{userId}")]
public IActionResult GetStatus(Guid userId)
public async Task<IActionResult> GetStatus(Guid userId)
{
try
{
return Ok(_presenceService.WhenUserWasOnline(userId));
var isOnline = _userOnlineStore.IsOnline(userId);
var lastSeen = await _presenceReader.GetLastSeenAsync(userId);
return Ok(new {
isOnline,
lastSeen
});
}
catch (Exception e)
{