feat: added RabbitMQ queue from back-end to hook auth for client

This commit is contained in:
2025-07-25 16:27:27 +03:00
parent 06367a3ccd
commit 8c9973e55d
4 changed files with 32 additions and 4 deletions

View File

@@ -1,14 +1,19 @@
using System.Text;
using System.Text.Json;
using System.Web;
using JOBot.Backend.DAL.Context;
using JOBot.Backend.DTOs.HeadHunterHook;
using JOBot.Backend.Infrastructure.Config;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using RabbitMQ.Client;
namespace JOBot.Backend.Services;
public class HeadHunterService(ILogger<HeadHunterService> logger, IOptions<HeadHunterConfig> config, AppDbContext dbContext)
public class HeadHunterService(
IChannel channel,
ILogger<HeadHunterService> logger,
IOptions<HeadHunterConfig> config,
AppDbContext dbContext)
{
private readonly HeadHunterConfig _config = config.Value;
@@ -88,6 +93,14 @@ public class HeadHunterService(ILogger<HeadHunterService> logger, IOptions<HeadH
await dbContext.SaveChangesAsync();
logger.LogInformation($"User {userId} auth completed!");
await channel.BasicPublishAsync(
string.Empty,
RabbitQueues.AuthQueue,
Encoding.UTF8.GetBytes(userId.ToString()));
logger.LogInformation($"RabbitMQ event was created");
return Status.Success;
}