diff --git a/JOBot.Backend/JOBot.Backend.csproj b/JOBot.Backend/JOBot.Backend.csproj
index 6526b76..f814b31 100644
--- a/JOBot.Backend/JOBot.Backend.csproj
+++ b/JOBot.Backend/JOBot.Backend.csproj
@@ -31,4 +31,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/JOBot.Backend/Services/HeadHunterService.cs b/JOBot.Backend/Services/HeadHunterService.cs
index 8ff1787..3395a22 100644
--- a/JOBot.Backend/Services/HeadHunterService.cs
+++ b/JOBot.Backend/Services/HeadHunterService.cs
@@ -3,6 +3,7 @@ using System.Text.Json;
using JOBot.Backend.DAL.Context;
using JOBot.Backend.DTOs.HeadHunterHook;
using JOBot.Backend.Infrastructure.Config;
+using JOBot.Infrastructure.Config;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using RabbitMQ.Client;
diff --git a/JOBot.Backend/Startup.cs b/JOBot.Backend/Startup.cs
index 6890d1e..957d184 100644
--- a/JOBot.Backend/Startup.cs
+++ b/JOBot.Backend/Startup.cs
@@ -2,6 +2,7 @@ using JOBot.Backend.DAL.Context;
using JOBot.Backend.Infrastructure.Config;
using JOBot.Backend.Services;
using JOBot.Backend.Services.gRPC;
+using JOBot.Infrastructure.Config;
using Microsoft.EntityFrameworkCore;
using RabbitMQ.Client;
@@ -22,8 +23,13 @@ public class Startup(IConfiguration configuration)
{
HostName = "jobot-rabbitmq"
}.CreateConnectionAsync();
- await using var channel = await rabbitMqConnection.CreateChannelAsync();
- await channel.QueueDeclareAsync(RabbitQueues.AuthQueue, false, false, false);
+ var channel = await rabbitMqConnection.CreateChannelAsync();
+ await channel.QueueDeclareAsync(
+ RabbitQueues.AuthQueue,
+ false,
+ false,
+ false,
+ arguments: null);
services.AddSingleton(channel);
services.AddDbContext(options =>
diff --git a/JOBot.Backend/Infrastructure/Config/RabbitQueues.cs b/JOBot.Infrastructure/Config/RabbitQueues.cs
similarity index 63%
rename from JOBot.Backend/Infrastructure/Config/RabbitQueues.cs
rename to JOBot.Infrastructure/Config/RabbitQueues.cs
index cc8de04..0525bdc 100644
--- a/JOBot.Backend/Infrastructure/Config/RabbitQueues.cs
+++ b/JOBot.Infrastructure/Config/RabbitQueues.cs
@@ -1,4 +1,4 @@
-namespace JOBot.Backend.Infrastructure.Config;
+namespace JOBot.Infrastructure.Config;
public static class RabbitQueues
{
diff --git a/JOBot.Infrastructure/JOBot.Infrastructure.csproj b/JOBot.Infrastructure/JOBot.Infrastructure.csproj
new file mode 100644
index 0000000..17b910f
--- /dev/null
+++ b/JOBot.Infrastructure/JOBot.Infrastructure.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net9.0
+ enable
+ enable
+
+
+
diff --git a/JOBot.TClient/JOBot.TClient.csproj b/JOBot.TClient/JOBot.TClient.csproj
index 5bcfbc3..9bce854 100644
--- a/JOBot.TClient/JOBot.TClient.csproj
+++ b/JOBot.TClient/JOBot.TClient.csproj
@@ -64,4 +64,8 @@
+
+
+
+
diff --git a/JOBot.TClient/Queues/AuthQueue.cs b/JOBot.TClient/Queues/AuthQueue.cs
new file mode 100644
index 0000000..e5b9498
--- /dev/null
+++ b/JOBot.TClient/Queues/AuthQueue.cs
@@ -0,0 +1,26 @@
+using System.Text;
+using JOBot.Infrastructure.Config;
+using JOBot.TClient.Services;
+using RabbitMQ.Client;
+using RabbitMQ.Client.Events;
+
+namespace JOBot.TClient.Queues;
+
+public class AuthQueue
+{
+ private readonly PrepareUserService _prepareUserService;
+ public AuthQueue(
+ IChannel channel, PrepareUserService prepareUserService)
+ {
+ _prepareUserService = prepareUserService;
+
+ var consumer = new AsyncEventingBasicConsumer(channel);
+ consumer.ReceivedAsync += OnDataReceivedAsync;
+ channel.BasicConsumeAsync(RabbitQueues.AuthQueue, autoAck: true, consumer: consumer);
+ }
+
+ private async Task OnDataReceivedAsync(object sender, BasicDeliverEventArgs eventArgs)
+ {
+ await _prepareUserService.SelectCv(Convert.ToInt64(Encoding.UTF8.GetString(eventArgs.Body.ToArray())));
+ }
+}
\ No newline at end of file
diff --git a/JOBot.TClient/Services/PrepareUserService.cs b/JOBot.TClient/Services/PrepareUserService.cs
index 4c6a71b..df61817 100644
--- a/JOBot.TClient/Services/PrepareUserService.cs
+++ b/JOBot.TClient/Services/PrepareUserService.cs
@@ -99,11 +99,22 @@ public class PrepareUserService(ITelegramBotClient bot, User.UserClient userClie
cancellationToken: ct);
}
+ public async Task AuthHookReceived(long userId, CancellationToken ct = default)
+ {
+ await _bot.SendMessage(userId, "Авторизация завершена успешно!", cancellationToken: ct);
+ await SelectCv(userId, ct);
+ }
+
public async Task SelectCv(Update update, CancellationToken ct = default)
{
ArgumentNullException.ThrowIfNull(update.Message?.From);
+
+ await SelectCv(update.Message.From.Id, ct);
+ }
- await _bot.SendMessage(update.Message.From.Id, "Давайте выберем одно из доступных резюме:",
+ public async Task SelectCv(long userId, CancellationToken ct = default)
+ {
+ await _bot.SendMessage(userId, "Давайте выберем одно из доступных резюме:",
cancellationToken: ct); //TODO: https://git.lisoveliy.su/Lisoveliy/JOBot/issues/9
}
}
\ No newline at end of file
diff --git a/JOBot.TClient/DependencyInjection.cs b/JOBot.TClient/Startup.cs
similarity index 75%
rename from JOBot.TClient/DependencyInjection.cs
rename to JOBot.TClient/Startup.cs
index 6594372..23630fd 100644
--- a/JOBot.TClient/DependencyInjection.cs
+++ b/JOBot.TClient/Startup.cs
@@ -1,19 +1,23 @@
using Grpc.Core;
using Grpc.Net.Client;
+using JOBot.Infrastructure.Config;
using JOBot.Proto;
using JOBot.TClient.Commands.Buttons;
using JOBot.TClient.Commands.Commands;
using JOBot.TClient.Core.HostedServices;
+using JOBot.TClient.Queues;
using JOBot.TClient.Services;
using JOBot.TClient.Statements;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
+using RabbitMQ.Client;
+using RabbitMQ.Client.Events;
using Telegram.Bot;
namespace JOBot.TClient;
-public static class DependencyInjection
+public static class Startup
{
public static IServiceCollection ConfigureServices(this IServiceCollection services, IConfiguration config)
{
@@ -53,6 +57,23 @@ public static class DependencyInjection
#endregion
+ #region RabbitMQ Clients
+
+ var factory = new ConnectionFactory { HostName = "localhost" };
+ using var connection = factory.CreateConnectionAsync().Result;
+ var channel = connection.CreateChannelAsync().Result;
+
+ channel.QueueDeclareAsync(
+ RabbitQueues.AuthQueue,
+ false,
+ false,
+ false,
+ arguments: null).Wait();
+
+ services.AddSingleton();
+
+ #endregion
+
// Bot service
services.AddHostedService();
services.AddSingleton(_ =>
diff --git a/JOBot.sln b/JOBot.sln
index e1513fe..0539a75 100644
--- a/JOBot.sln
+++ b/JOBot.sln
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JOBot.Backend", "JOBot.Back
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JOBot.TClient", "JOBot.TClient\JOBot.TClient.csproj", "{4526BCB1-DAD3-430C-BD7C-9C114DFE9A2A}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JOBot.Infrastructure", "JOBot.Infrastructure\JOBot.Infrastructure.csproj", "{32006B71-E6F7-4264-A8B4-AC3A6B77CC54}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -41,6 +43,18 @@ Global
{4526BCB1-DAD3-430C-BD7C-9C114DFE9A2A}.Release|x64.Build.0 = Release|Any CPU
{4526BCB1-DAD3-430C-BD7C-9C114DFE9A2A}.Release|x86.ActiveCfg = Release|Any CPU
{4526BCB1-DAD3-430C-BD7C-9C114DFE9A2A}.Release|x86.Build.0 = Release|Any CPU
+ {32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Debug|x64.Build.0 = Debug|Any CPU
+ {32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Debug|x86.Build.0 = Debug|Any CPU
+ {32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Release|Any CPU.Build.0 = Release|Any CPU
+ {32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Release|x64.ActiveCfg = Release|Any CPU
+ {32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Release|x64.Build.0 = Release|Any CPU
+ {32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Release|x86.ActiveCfg = Release|Any CPU
+ {32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE