mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
Refactor: migrate Core -> Domain and reorganize projects
Large refactor that renames/moves core types into a new Govor.Domain surface and reorganizes the Application layer. Models, configurations, migrations and many files moved from Govor.Core/Govor.Data to Govor.Domain; numerous Application services, interfaces and implementations were relocated or added (authentication, friends, messages, medias, push notifications, user sessions, storage, synching, private chats, etc.). Tests updated to use Govor.Domain namespaces and adjusted project references (removed Govor.Data reference from API tests). Also updated API, Hub and mapping code and project files to reflect the new structure and naming. This is primarily a codebase-wide namespace and module reorganization to establish a Domain project and restructure application services.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using Govor.API.Common.SignalR.Helpers;
|
||||
using Govor.Application.Interfaces.UserOnlineStatus;
|
||||
using Govor.Core.Repositories.Users;
|
||||
using Govor.Application.Users.UserOnlineStatus;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
@@ -15,17 +14,14 @@ public class PresenceHub : Hub
|
||||
private readonly IUserNotificationScopeService _scopeService;
|
||||
private readonly IOnlineUserStore _onlineUserStore;
|
||||
private readonly IHubUserAccessor _userAccessor;
|
||||
private readonly IUsersRepository _users;
|
||||
|
||||
public PresenceHub(
|
||||
ILogger<PresenceHub> logger,
|
||||
IUserNotificationScopeService scopeService,
|
||||
IOnlineUserStore onlineUserStore,
|
||||
IHubUserAccessor userAccessor,
|
||||
IUsersRepository users)
|
||||
IHubUserAccessor userAccessor)
|
||||
{
|
||||
_logger = logger;
|
||||
_users = users;
|
||||
_scopeService = scopeService;
|
||||
_onlineUserStore = onlineUserStore;
|
||||
_userAccessor = userAccessor;
|
||||
@@ -79,32 +75,9 @@ public class PresenceHub : Hub
|
||||
|
||||
if (isLastConnection)
|
||||
{
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(5));
|
||||
|
||||
var currentConnections = _onlineUserStore.GetConnections(userId);
|
||||
if (currentConnections == null || !currentConnections.Any())
|
||||
{
|
||||
var friends = await _scopeService.GetNotifiedUsers(userId);
|
||||
await Clients.Groups(friends.Select(f => f.ToString()).ToList())
|
||||
.SendAsync("UserOffline", userId);
|
||||
|
||||
try
|
||||
{
|
||||
var user = await _users.FindByIdAsync(userId);
|
||||
if (user != null)
|
||||
{
|
||||
user.WasOnline = DateTime.UtcNow;
|
||||
await _users.UpdateAsync(user);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error updating WasOnline for {UserId}", userId);
|
||||
}
|
||||
}
|
||||
});
|
||||
var friends = await _scopeService.GetNotifiedUsers(userId);
|
||||
await Clients.Groups(friends.Select(f => f.ToString()).ToList())
|
||||
.SendAsync("UserOffline", userId);
|
||||
}
|
||||
|
||||
await base.OnDisconnectedAsync(exception);
|
||||
|
||||
Reference in New Issue
Block a user