[FA-55] User service should be done
Some checks failed
CI / build-backend (pull_request) Successful in 2m2s
CI / build-frontend (pull_request) Failing after 30s

This commit is contained in:
gamer147
2025-12-29 14:33:08 -05:00
parent 01d3b94050
commit ebb2e6e7fc
3 changed files with 39 additions and 3 deletions

View File

@@ -1,4 +1,6 @@
using FictionArchive.Service.Shared.Services.EventBus;
using FictionArchive.Service.UserService.Models.Database;
using FictionArchive.Service.UserService.Models.IntegrationEvents;
using FictionArchive.Service.UserService.Services.AuthenticationClient;
using Microsoft.EntityFrameworkCore;
@@ -9,15 +11,18 @@ public class UserManagementService
private readonly ILogger<UserManagementService> _logger;
private readonly UserServiceDbContext _dbContext;
private readonly IAuthenticationServiceClient _authClient;
private readonly IEventBus _eventBus;
public UserManagementService(
UserServiceDbContext dbContext,
ILogger<UserManagementService> logger,
IAuthenticationServiceClient authClient)
IAuthenticationServiceClient authClient,
IEventBus eventBus)
{
_dbContext = dbContext;
_logger = logger;
_authClient = authClient;
_eventBus = eventBus;
}
/// <summary>
@@ -94,6 +99,17 @@ public class UserManagementService
await _dbContext.SaveChangesAsync();
await _eventBus.Publish(new UserInvitedEvent
{
InvitedUserId = newUser.Id,
InvitedUsername = newUser.Username,
InvitedEmail = newUser.Email,
InvitedOAuthProviderId = newUser.OAuthProviderId,
InviterId = inviter.Id,
InviterUsername = inviter.Username,
InviterOAuthProviderId = inviter.OAuthProviderId
});
_logger.LogInformation(
"User {Username} was successfully invited by {InviterId}. New user id: {NewUserId}",
username, inviter.Id, newUser.Id);