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:
Artemy
2026-07-16 19:27:45 +07:00
parent 1d35356c8c
commit 6d1c53beeb
371 changed files with 2729 additions and 6694 deletions
@@ -1,4 +1,4 @@
using Govor.Application.Interfaces.UserSession;
using Govor.Application.Users.UserSessions;
using Govor.Contracts.Requests;
using Govor.Contracts.Responses;
using Microsoft.AspNetCore.Authorization;
@@ -13,7 +13,7 @@ public class RefreshController : Controller
{
private readonly ILogger<RefreshController> _logger;
private readonly IUserSessionRefresher _userSession;
public RefreshController(
ILogger<RefreshController> logger,
IUserSessionRefresher userSession)
@@ -21,41 +21,35 @@ public class RefreshController : Controller
_logger = logger;
_userSession = userSession;
}
//[RequireHttps]
[HttpPost("refresh")] // api/auth/token/refresh
public async Task<IActionResult> Refresh([FromBody] RefreshTokenRequest refreshRequest)
{
try
if (string.IsNullOrWhiteSpace(refreshRequest.RefreshToken))
{
if (!ModelState.IsValid)
return BadRequest(ModelState);
if (string.IsNullOrEmpty(refreshRequest.RefreshToken))
throw new InvalidOperationException("Refresh token cant be empty.");
var result = await _userSession.RefreshTokenAsync(refreshRequest.RefreshToken);
_logger.LogWarning("Refresh request failed: token is empty.");
return BadRequest("Refresh token can't be empty.");
}
var result = await _userSession.RefreshTokenAsync(refreshRequest.RefreshToken);
return Ok(new RefreshTokenResponse()
{
AccessToken = result.accessToken,
RefreshToken = result.refreshToken
});
}
catch (InvalidOperationException ex)
if (result.IsFailure)
{
_logger.LogWarning(ex, "Invalid refresh token.");
return BadRequest(ex.Message);
_logger.LogWarning("Refresh token failed. Error Code: {Code}", result.Error.Code);
return result.Error.Code switch
{
"Auth.EmptyToken" => BadRequest(result.Error.Message),
"Auth.InvalidToken" => Unauthorized(result.Error.Message),
_ => BadRequest($"Refresh failed: {result.Error.Message}")
};
}
catch (UnauthorizedAccessException ex)
return Ok(new RefreshTokenResponse
{
_logger.LogWarning(ex, "Refresh token failed.");
return Unauthorized("Invalid refresh token");
}
catch (Exception ex)
{
_logger.LogError(ex, ex.Message);
return StatusCode(500, "An unexpected error occurred.");
}
AccessToken = result.Value.accessToken,
RefreshToken = result.Value.refreshToken
});
}
}