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:
@@ -0,0 +1,46 @@
|
||||
using Govor.Domain;
|
||||
using Govor.Domain.Common;
|
||||
using Govor.Domain.Models.Users;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Govor.Application.Users.UserSessions;
|
||||
|
||||
public class UserSessionReader : IUserSessionReader
|
||||
{
|
||||
private readonly GovorDbContext _context;
|
||||
private readonly ILogger<UserSessionReader> _logger;
|
||||
|
||||
public UserSessionReader(GovorDbContext context, ILogger<UserSessionReader> logger)
|
||||
{
|
||||
_context = context;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<Result<List<UserSession>>> GetAllSessionsAsync(Guid userId)
|
||||
{
|
||||
if (userId == Guid.Empty)
|
||||
{
|
||||
return Result<List<UserSession>>.Failure(new Error(
|
||||
"UserSession.InvalidUserId",
|
||||
"Provided User ID cannot be empty."));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Getting all active sessions for user {UserId}", userId);
|
||||
|
||||
try
|
||||
{
|
||||
var sessions = await _context.UserSessions
|
||||
.AsNoTracking()
|
||||
.Where(s => s.UserId == userId && !s.IsRevoked)
|
||||
.ToListAsync();
|
||||
|
||||
return sessions;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Failed to fetch user sessions for user {UserId}", userId);
|
||||
return Result<List<UserSession>>.Failure(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user