[FA-misc] Initial MassTransit implementation seems to work
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
using FictionArchive.Service.Shared.Services.EventBus;
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
using FictionArchive.Service.UserService.Contracts;
|
||||
using FictionArchive.Service.UserService.Models.Database;
|
||||
using FictionArchive.Service.UserService.Models.IntegrationEvents;
|
||||
using FictionArchive.Service.UserService.Services.AuthenticationClient;
|
||||
using MassTransit;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FictionArchive.Service.UserService.Services;
|
||||
@@ -11,18 +12,18 @@ public class UserManagementService
|
||||
private readonly ILogger<UserManagementService> _logger;
|
||||
private readonly UserServiceDbContext _dbContext;
|
||||
private readonly IAuthenticationServiceClient _authClient;
|
||||
private readonly IEventBus _eventBus;
|
||||
private readonly IPublishEndpoint _publishEndpoint;
|
||||
|
||||
public UserManagementService(
|
||||
UserServiceDbContext dbContext,
|
||||
ILogger<UserManagementService> logger,
|
||||
IAuthenticationServiceClient authClient,
|
||||
IEventBus eventBus)
|
||||
IPublishEndpoint publishEndpoint)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_logger = logger;
|
||||
_authClient = authClient;
|
||||
_eventBus = eventBus;
|
||||
_publishEndpoint = publishEndpoint;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -99,16 +100,14 @@ 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
|
||||
});
|
||||
await _publishEndpoint.Publish<IUserInvited>(new UserInvited(
|
||||
InvitedUserId: newUser.Id.ToString(),
|
||||
InvitedUsername: newUser.Username,
|
||||
InvitedEmail: newUser.Email,
|
||||
InvitedOAuthProviderId: newUser.OAuthProviderId,
|
||||
InviterId: inviter.Id.ToString(),
|
||||
InviterUsername: inviter.Username,
|
||||
InviterOAuthProviderId: inviter.OAuthProviderId));
|
||||
|
||||
_logger.LogInformation(
|
||||
"User {Username} was successfully invited by {InviterId}. New user id: {NewUserId}",
|
||||
|
||||
Reference in New Issue
Block a user