Compare commits
39 Commits
cb481e6af6
...
8
| Author | SHA1 | Date | |
|---|---|---|---|
| dd1364f744 | |||
| 171757705a | |||
| 7c22b4b9a7 | |||
| 9a7f178023 | |||
| 156ce579d4 | |||
| 0c6b8705ee | |||
| 3085d5e778 | |||
| 8b1ead20c9 | |||
| 176cf194cd | |||
| 17cec6dd64 | |||
| 0f1c7581b8 | |||
| 970526d84e | |||
| f115760713 | |||
| d2280cdc5b | |||
| b15a77557e | |||
| 7ceb8f656e | |||
| 8c9973e55d | |||
| 06367a3ccd | |||
| 1f3d4525d8 | |||
| 8018cb6496 | |||
| 003d2201e5 | |||
| 8de65abea5 | |||
| 0e9084ce2e | |||
| f2aadf43a6 | |||
| 48b79ce6ea | |||
| 81bf05e3fc | |||
| 445a1f7fa4 | |||
| 2f79bd336a | |||
| cf463a5d94 | |||
| f6500670c0 | |||
| 1f0bc01dc6 | |||
| 18e6fcc883 | |||
| 10d0a83e15 | |||
| 3b8278ba66 | |||
| 86cad2beec | |||
| 4b223ecf98 | |||
| d041fd870b | |||
| 6d5c327747 | |||
| 7e24a7444e |
24
.gitea/workflows/deploy-dev.yml
Normal file
24
.gitea/workflows/deploy-dev.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
name: Publish JOBot on dev
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build and deploy:
|
||||||
|
runs-on: host
|
||||||
|
name: Build and deploy
|
||||||
|
volumes:
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Update repo
|
||||||
|
run: |
|
||||||
|
pwd
|
||||||
|
cd /home/dockeruser/jobot-stack
|
||||||
|
git checkout dev
|
||||||
|
git pull
|
||||||
|
docker compose -f compose.dev.yml up -d postgres
|
||||||
|
|
||||||
|
cd /home/dockeruser/jobot-stack/JOBot.Backend
|
||||||
|
dotnet ef database update --connection "Host=localhost;Port=5432;Database=jobot;Username=postgres;Password=LocalDbPass"
|
||||||
|
docker compose up --build -d
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -404,6 +404,7 @@ FodyWeavers.xsd
|
|||||||
.docker
|
.docker
|
||||||
|
|
||||||
# Secrets
|
# Secrets
|
||||||
|
JOBot.Backend/appsettings.Development.json
|
||||||
JOBot.TClient/appsettings.json
|
JOBot.TClient/appsettings.json
|
||||||
/.idea/.idea.JOBot/Docker/compose.generated.override.yml
|
/.idea/.idea.JOBot/Docker/compose.generated.override.yml
|
||||||
/.idea/.idea.JOBot/Docker/compose.dev.generated.override.yml
|
/.idea/.idea.JOBot/Docker/compose.dev.generated.override.yml
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ namespace JOBot.Backend.Controllers;
|
|||||||
public class HeadHunterHookController(HeadHunterService hhService)
|
public class HeadHunterHookController(HeadHunterService hhService)
|
||||||
: ControllerBase
|
: ControllerBase
|
||||||
{
|
{
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> Get(int userId, string? error, string code)
|
public async Task<IActionResult> Get(int userId, string? error, string code)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
namespace JOBot.Backend.DAL.Context;
|
using JOBot.Backend.DAL.Models;
|
||||||
|
|
||||||
using Models;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace JOBot.Backend.DAL.Context;
|
||||||
|
|
||||||
public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
|
public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
|
||||||
{
|
{
|
||||||
public DbSet<User> Users { get; set; }
|
public DbSet<User> Users { get; set; }
|
||||||
|
|||||||
@@ -9,17 +9,19 @@ public class User
|
|||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
[Key]
|
[Key] public required long UserId { get; set; }
|
||||||
public required long UserId { get; set; }
|
|
||||||
[MaxLength(255)]
|
[MaxLength(255)] public string? Username { get; set; }
|
||||||
public string? Username { get; set; }
|
|
||||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
[MaxLength(255)] public string? AccessToken { get; set; } = null;
|
[MaxLength(255)] public string? AccessToken { get; set; }
|
||||||
[MaxLength(255)] public string? RefreshToken { get; set; } = null;
|
[MaxLength(255)] public string? RefreshToken { get; set; }
|
||||||
|
|
||||||
public bool Eula { get; set; } = false;
|
public long? ExpiresIn { get; set; } = null;
|
||||||
[MaxLength(255)] public string? CvUrl { get; set; } = null;
|
|
||||||
|
public bool Eula { get; set; }
|
||||||
|
[MaxLength(255)] public string? CvUrl { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Негоже это маппинги в DAL ложить
|
//TODO: Негоже это маппинги в DAL ложить
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace JOBot.Backend.DTOs.HeadHunterApi;
|
||||||
|
|
||||||
|
public record HeadHunterTokenResponseDto(
|
||||||
|
[property: JsonPropertyName("access_token")]
|
||||||
|
string AccessToken,
|
||||||
|
[property: JsonPropertyName("expires_in")]
|
||||||
|
int ExpiresIn,
|
||||||
|
[property: JsonPropertyName("refresh_token")]
|
||||||
|
string RefreshToken,
|
||||||
|
[property: JsonPropertyName("token_type")]
|
||||||
|
string TokenType
|
||||||
|
);
|
||||||
21
JOBot.Backend/DTOs/HeadHunterApi/ListOfResumeResponseDto.cs
Normal file
21
JOBot.Backend/DTOs/HeadHunterApi/ListOfResumeResponseDto.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace JOBot.Backend.DTOs.HeadHunterApi;
|
||||||
|
|
||||||
|
public class ListOfResumeResponseDto
|
||||||
|
{
|
||||||
|
[JsonPropertyName("found")]
|
||||||
|
public bool Found { get; set; }
|
||||||
|
[JsonPropertyName("items")]
|
||||||
|
public List<Resume> Items { get; set; } = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Resume
|
||||||
|
{
|
||||||
|
[JsonPropertyName("can_publish_or_update")]
|
||||||
|
public bool CanPublishOrUpdate { get; set; }
|
||||||
|
[JsonPropertyName("title")]
|
||||||
|
public string Title { get; set; } = null!;
|
||||||
|
[JsonPropertyName("url")]
|
||||||
|
public string Url { get; set; } = null!;
|
||||||
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
using System.Text.Json.Serialization;
|
|
||||||
|
|
||||||
namespace JOBot.Backend.DTOs.HeadHunterHook;
|
|
||||||
|
|
||||||
public record HeadHunterTokenResponseDto(
|
|
||||||
[property:JsonPropertyName("access_token")]
|
|
||||||
string AccessToken,
|
|
||||||
[property:JsonPropertyName("expires_in")]
|
|
||||||
int ExpiresIn,
|
|
||||||
[property:JsonPropertyName("refresh_token")]
|
|
||||||
string RefreshToken,
|
|
||||||
[property:JsonPropertyName("token_type")]
|
|
||||||
string TokenType
|
|
||||||
);
|
|
||||||
@@ -20,14 +20,22 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4"/>
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4"/>
|
||||||
|
<PackageReference Include="RabbitMQ.Client" Version="7.1.2"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Protobuf Include="..\Proto\*" GrpcServices="Server"></Protobuf>
|
<Protobuf Include="..\Proto\*" GrpcServices="Server"></Protobuf>
|
||||||
|
<Protobuf Update="..\Proto\resume.proto">
|
||||||
|
<Link>Proto\resume.proto</Link>
|
||||||
|
</Protobuf>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Data\Migrations\"/>
|
<Folder Include="Data\Migrations\"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\JOBot.Infrastructure\JOBot.Infrastructure.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,15 +1,32 @@
|
|||||||
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Web;
|
|
||||||
using JOBot.Backend.DAL.Context;
|
using JOBot.Backend.DAL.Context;
|
||||||
using JOBot.Backend.DTOs.HeadHunterHook;
|
using JOBot.Backend.DAL.Models;
|
||||||
|
using JOBot.Backend.DTOs.HeadHunterApi;
|
||||||
using JOBot.Backend.Infrastructure.Config;
|
using JOBot.Backend.Infrastructure.Config;
|
||||||
|
using JOBot.Infrastructure.Config;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using RabbitMQ.Client;
|
||||||
|
|
||||||
namespace JOBot.Backend.Services;
|
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,
|
||||||
|
IWebHostEnvironment env,
|
||||||
|
AppDbContext dbContext)
|
||||||
{
|
{
|
||||||
|
public enum Status
|
||||||
|
{
|
||||||
|
UserAuthRejectedError,
|
||||||
|
HeadHunterAuthRejectedError,
|
||||||
|
UserNotFoundError,
|
||||||
|
HeadHunterResponseDeserializationFailedError,
|
||||||
|
Success
|
||||||
|
}
|
||||||
|
|
||||||
private readonly HeadHunterConfig _config = config.Value;
|
private readonly HeadHunterConfig _config = config.Value;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -19,11 +36,17 @@ public class HeadHunterService(ILogger<HeadHunterService> logger, IOptions<HeadH
|
|||||||
/// <returns>Link for auth</returns>
|
/// <returns>Link for auth</returns>
|
||||||
public string GenerateAuthLink(long userId)
|
public string GenerateAuthLink(long userId)
|
||||||
{
|
{
|
||||||
|
|
||||||
return string.Format(_config.Links.AuthLink, [_config.ClientId, GetRedirectUrl(userId)]);
|
return string.Format(_config.Links.AuthLink, [_config.ClientId, GetRedirectUrl(userId)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Status> AuthUser(int userId, string authorizationCode, string? error)
|
/// <summary>
|
||||||
|
/// Auth user on HeadHunter API
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <param name="authorizationCode"></param>
|
||||||
|
/// <param name="error"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<Status> AuthUser(int userId, string authorizationCode, string? error) //TODO: Разбить этот метод
|
||||||
{
|
{
|
||||||
logger.LogInformation($"Authorization for user {userId} in process...");
|
logger.LogInformation($"Authorization for user {userId} in process...");
|
||||||
|
|
||||||
@@ -33,6 +56,9 @@ public class HeadHunterService(ILogger<HeadHunterService> logger, IOptions<HeadH
|
|||||||
return Status.UserAuthRejectedError;
|
return Status.UserAuthRejectedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HeadHunterTokenResponseDto? responseDto;
|
||||||
|
if (!env.IsDevelopment()) //Production server
|
||||||
|
{
|
||||||
using var client = new HttpClient();
|
using var client = new HttpClient();
|
||||||
var form = new Dictionary<string, string>
|
var form = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
@@ -65,7 +91,8 @@ public class HeadHunterService(ILogger<HeadHunterService> logger, IOptions<HeadH
|
|||||||
return Status.HeadHunterAuthRejectedError;
|
return Status.HeadHunterAuthRejectedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
var responseDto = JsonSerializer.Deserialize<HeadHunterTokenResponseDto>(await res.Content.ReadAsStringAsync());
|
responseDto =
|
||||||
|
JsonSerializer.Deserialize<HeadHunterTokenResponseDto>(await res.Content.ReadAsStringAsync());
|
||||||
|
|
||||||
if (responseDto == null)
|
if (responseDto == null)
|
||||||
{
|
{
|
||||||
@@ -73,6 +100,11 @@ public class HeadHunterService(ILogger<HeadHunterService> logger, IOptions<HeadH
|
|||||||
$"{nameof(Status.HeadHunterResponseDeserializationFailedError)}");
|
$"{nameof(Status.HeadHunterResponseDeserializationFailedError)}");
|
||||||
return Status.HeadHunterResponseDeserializationFailedError;
|
return Status.HeadHunterResponseDeserializationFailedError;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
responseDto = new HeadHunterTokenResponseDto("testtoken", 0, "testtoken", "--");
|
||||||
|
}
|
||||||
|
|
||||||
var user = await dbContext.Users.FirstOrDefaultAsync(x => x.UserId == userId);
|
var user = await dbContext.Users.FirstOrDefaultAsync(x => x.UserId == userId);
|
||||||
|
|
||||||
@@ -84,10 +116,63 @@ public class HeadHunterService(ILogger<HeadHunterService> logger, IOptions<HeadH
|
|||||||
|
|
||||||
user.AccessToken = responseDto.AccessToken;
|
user.AccessToken = responseDto.AccessToken;
|
||||||
user.RefreshToken = responseDto.RefreshToken;
|
user.RefreshToken = responseDto.RefreshToken;
|
||||||
|
user.ExpiresIn = responseDto.ExpiresIn;
|
||||||
|
|
||||||
await dbContext.SaveChangesAsync();
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
logger.LogInformation($"User {userId} auth completed!");
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Status> UpdateUserAccessToken(User user)
|
||||||
|
{
|
||||||
|
if (user.RefreshToken == null)
|
||||||
|
return Status.UserAuthRejectedError;
|
||||||
|
|
||||||
|
using var client = new HttpClient(); //TODO: Написать wrapper для работы с HH API
|
||||||
|
var form = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "refresh_token", user.RefreshToken },
|
||||||
|
{ "grant_type", "refresh_token" }
|
||||||
|
};
|
||||||
|
client.BaseAddress = new UriBuilder(_config.Links.HeadHunterApiDomain)
|
||||||
|
{
|
||||||
|
Port = -1,
|
||||||
|
Scheme = "https"
|
||||||
|
}.Uri;
|
||||||
|
client.DefaultRequestHeaders.UserAgent.ParseAdd("Jobot BackEnd Service");
|
||||||
|
|
||||||
|
using var res = await client.SendAsync(
|
||||||
|
new HttpRequestMessage(
|
||||||
|
HttpMethod.Post,
|
||||||
|
_config.Links.HeadHunterTokenRoute)
|
||||||
|
{
|
||||||
|
Content = new FormUrlEncodedContent(form)
|
||||||
|
});
|
||||||
|
|
||||||
|
var responseDto =
|
||||||
|
JsonSerializer.Deserialize<HeadHunterTokenResponseDto>(await res.Content.ReadAsStringAsync());
|
||||||
|
|
||||||
|
if (responseDto == null)
|
||||||
|
{
|
||||||
|
logger.LogWarning(
|
||||||
|
$"User {user.Username ?? user.UserId.ToString()} access token accept completed with error " +
|
||||||
|
$"{nameof(Status.HeadHunterResponseDeserializationFailedError)}");
|
||||||
|
return Status.HeadHunterResponseDeserializationFailedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
user.RefreshToken = responseDto.RefreshToken;
|
||||||
|
user.AccessToken = responseDto.AccessToken;
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
return Status.Success;
|
return Status.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,13 +186,4 @@ public class HeadHunterService(ILogger<HeadHunterService> logger, IOptions<HeadH
|
|||||||
Query = $"?userId={userId}"
|
Query = $"?userId={userId}"
|
||||||
}.ToString();
|
}.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Status
|
|
||||||
{
|
|
||||||
UserAuthRejectedError,
|
|
||||||
HeadHunterAuthRejectedError,
|
|
||||||
UserNotFoundError,
|
|
||||||
HeadHunterResponseDeserializationFailedError,
|
|
||||||
Success
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
68
JOBot.Backend/Services/ResumeService.cs
Normal file
68
JOBot.Backend/Services/ResumeService.cs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text.Json;
|
||||||
|
using JOBot.Backend.DAL.Context;
|
||||||
|
using JOBot.Backend.DTOs.HeadHunterApi;
|
||||||
|
using JOBot.Backend.Infrastructure.Config;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
namespace JOBot.Backend.Services;
|
||||||
|
|
||||||
|
public class ResumeService(
|
||||||
|
AppDbContext dbContext,
|
||||||
|
ILogger<ResumeService> logger,
|
||||||
|
IOptions<HeadHunterConfig> config,
|
||||||
|
HeadHunterService headHunterService)
|
||||||
|
{
|
||||||
|
public async Task<(Status Status, List<Resume>? Resume)> GetAvailableResumes(long userId)
|
||||||
|
{
|
||||||
|
var user = await dbContext.Users.FirstOrDefaultAsync(x => x.UserId == userId);
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return new(Status.UserNotFound, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!user.ExpiresIn.HasValue || new DateTime().AddSeconds(user.ExpiresIn.Value) > DateTime.Now)
|
||||||
|
{
|
||||||
|
var status = await headHunterService.UpdateUserAccessToken(user);
|
||||||
|
if (status != HeadHunterService.Status.Success)
|
||||||
|
{
|
||||||
|
logger.LogError($"User {userId} has expired access and update of it was unsuccessful: {status}");
|
||||||
|
return (Status.TokenExpired, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
using var client = new HttpClient(); //TODO: Написать wrapper для работы с HH API
|
||||||
|
client.BaseAddress = new UriBuilder(config.Value.Links.HeadHunterApiDomain)
|
||||||
|
{
|
||||||
|
Port = -1,
|
||||||
|
Scheme = "https"
|
||||||
|
}.Uri;
|
||||||
|
client.DefaultRequestHeaders.UserAgent.ParseAdd("Jobot BackEnd Service");
|
||||||
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", user.AccessToken);
|
||||||
|
|
||||||
|
using var res = await client.GetAsync("/resumes/mine");
|
||||||
|
|
||||||
|
if (!res.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
logger.LogWarning(
|
||||||
|
$"User {user.Username ?? user.UserId.ToString()} resume list is unavailable by unsuccessful status code: {res.StatusCode}");
|
||||||
|
return new(Status.RequestError, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
var responseDto = JsonSerializer.Deserialize<ListOfResumeResponseDto>(await res.Content.ReadAsStringAsync());
|
||||||
|
if (responseDto == null)
|
||||||
|
return new(Status.Error, null);
|
||||||
|
|
||||||
|
return new(Status.Success, responseDto.Items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Status
|
||||||
|
{
|
||||||
|
Success,
|
||||||
|
UserNotFound,
|
||||||
|
Error,
|
||||||
|
RequestError,
|
||||||
|
TokenExpired
|
||||||
|
}
|
||||||
|
}
|
||||||
46
JOBot.Backend/Services/gRPC/ResumeService.cs
Normal file
46
JOBot.Backend/Services/gRPC/ResumeService.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using Grpc.Core;
|
||||||
|
using JOBot.Backend.DAL.Context;
|
||||||
|
using JOBot.Proto;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace JOBot.Backend.Services.gRPC;
|
||||||
|
|
||||||
|
public class ResumeService(AppDbContext dbContext, Backend.Services.ResumeService resumeService)
|
||||||
|
: Proto.Resume.ResumeBase
|
||||||
|
{
|
||||||
|
public override async Task<GetResumeResponse> GetResume(GetResumeRequest request, ServerCallContext context)
|
||||||
|
{
|
||||||
|
var user = await dbContext.Users.FirstOrDefaultAsync(x => x.UserId == request.UserId);
|
||||||
|
if (user == null)
|
||||||
|
throw new RpcException(new Status(StatusCode.NotFound, "User not found"));
|
||||||
|
|
||||||
|
return new GetResumeResponse { ResumeUrl = user.CvUrl };
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task<GetAvailableResponse> GetAvailable(GetAvailableRequest request,
|
||||||
|
ServerCallContext context)
|
||||||
|
{
|
||||||
|
var response = await resumeService.GetAvailableResumes(request.UserId);
|
||||||
|
|
||||||
|
switch (response.Status)
|
||||||
|
{
|
||||||
|
case Services.ResumeService.Status.UserNotFound:
|
||||||
|
throw new RpcException(new Status(StatusCode.NotFound, "User not found"));
|
||||||
|
case Services.ResumeService.Status.Error:
|
||||||
|
throw new RpcException(new Status(StatusCode.Internal, "Unknown error"));
|
||||||
|
case Services.ResumeService.Status.Success:
|
||||||
|
{
|
||||||
|
var resp = new GetAvailableResponse();
|
||||||
|
resp.Resumes.AddRange(response.Resume!.ConvertAll(x => new ResumeDesc
|
||||||
|
{
|
||||||
|
Name = x.Title,
|
||||||
|
ResumeUrl = x.Url
|
||||||
|
}));
|
||||||
|
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw new RpcException(new Status(StatusCode.Unimplemented, "Unimplemented statement"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
using Google.Protobuf.WellKnownTypes;
|
|
||||||
using Grpc.Core;
|
using Grpc.Core;
|
||||||
using JOBot.Backend.DAL.Context;
|
using JOBot.Backend.DAL.Context;
|
||||||
using JOBot.Backend.DAL.Models;
|
using JOBot.Backend.DAL.Models;
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ using JOBot.Backend.DAL.Context;
|
|||||||
using JOBot.Backend.Infrastructure.Config;
|
using JOBot.Backend.Infrastructure.Config;
|
||||||
using JOBot.Backend.Services;
|
using JOBot.Backend.Services;
|
||||||
using JOBot.Backend.Services.gRPC;
|
using JOBot.Backend.Services.gRPC;
|
||||||
|
using JOBot.Infrastructure.Config;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using RabbitMQ.Client;
|
||||||
|
|
||||||
namespace JOBot.Backend;
|
namespace JOBot.Backend;
|
||||||
|
|
||||||
@@ -20,6 +22,23 @@ public class Startup(IConfiguration configuration)
|
|||||||
services.AddDbContext<AppDbContext>(options =>
|
services.AddDbContext<AppDbContext>(options =>
|
||||||
options.UseNpgsql(Configuration.GetConnectionString("PostgreSQL")));
|
options.UseNpgsql(Configuration.GetConnectionString("PostgreSQL")));
|
||||||
|
|
||||||
|
|
||||||
|
services.AddSingleton<IChannel>(x =>
|
||||||
|
{
|
||||||
|
var rabbitMqConnection = new ConnectionFactory
|
||||||
|
{
|
||||||
|
HostName = "rabbitmq"
|
||||||
|
}.CreateConnectionAsync().Result;
|
||||||
|
var channel = rabbitMqConnection.CreateChannelAsync().Result;
|
||||||
|
channel.QueueDeclareAsync(
|
||||||
|
RabbitQueues.AuthQueue,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
arguments: null).Wait();
|
||||||
|
return channel;
|
||||||
|
});
|
||||||
|
|
||||||
services.Configure<HeadHunterConfig>(Configuration.GetSection(HeadHunterConfig.SectionName));
|
services.Configure<HeadHunterConfig>(Configuration.GetSection(HeadHunterConfig.SectionName));
|
||||||
|
|
||||||
services.AddScoped<HeadHunterService>();
|
services.AddScoped<HeadHunterService>();
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ConnectionStrings": {
|
|
||||||
"PostgreSQL": "Host=localhost;Port=5432;Database=jobot;Username=postgres;Password=LocalDbPass"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*",
|
|
||||||
"ConnectionStrings": {
|
|
||||||
"PostgreSQL": "Host=postgres;Port=5432;Database=jobot_test;Username=postgres;Password=LocalDbPass"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
6
JOBot.Infrastructure/Config/RabbitQueues.cs
Normal file
6
JOBot.Infrastructure/Config/RabbitQueues.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace JOBot.Infrastructure.Config;
|
||||||
|
|
||||||
|
public static class RabbitQueues
|
||||||
|
{
|
||||||
|
public const string AuthQueue = "auth";
|
||||||
|
}
|
||||||
9
JOBot.Infrastructure/JOBot.Infrastructure.csproj
Normal file
9
JOBot.Infrastructure/JOBot.Infrastructure.csproj
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<root>
|
<root>
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root"
|
||||||
|
xmlns="">
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
@@ -13,10 +14,14 @@
|
|||||||
<value>1.3</value>
|
<value>1.3</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<resheader name="reader">
|
<resheader name="reader">
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||||
|
PublicKeyToken=b77a5c561934e089
|
||||||
|
</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||||
|
PublicKeyToken=b77a5c561934e089
|
||||||
|
</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<data name="EULAAgrement" xml:space="preserve">
|
<data name="EULAAgrement" xml:space="preserve">
|
||||||
<value>Соглашаюсь с условиями использования ✅</value>
|
<value>Соглашаюсь с условиями использования ✅</value>
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
using JOBot.Proto;
|
using JOBot.Proto;
|
||||||
using JOBot.TClient.Infrastructure.Attributes.Authorization;
|
using JOBot.TClient.Infrastructure.Attributes.Authorization;
|
||||||
using JOBot.TClient.Services;
|
|
||||||
using JOBot.TClient.Statements;
|
using JOBot.TClient.Statements;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using Telegram.Bot.Types.Enums;
|
|
||||||
|
|
||||||
namespace JOBot.TClient.Commands.Buttons;
|
namespace JOBot.TClient.Commands.Buttons;
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using JOBot.TClient.Infrastructure.Extensions;
|
||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
|
|
||||||
@@ -9,6 +10,6 @@ public class InfoCommand(ITelegramBotClient bot) : ITelegramCommand
|
|||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
||||||
|
|
||||||
await bot.SendMessage(update.Message.From.Id, TextResource.Info, cancellationToken: ct);
|
await bot.SendMessageRemK(update.Message.From.Id, TextResource.Info, cancellationToken: ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
using JOBot.Proto;
|
using JOBot.Proto;
|
||||||
using Telegram.Bot;
|
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
|
|
||||||
namespace JOBot.TClient.Commands;
|
namespace JOBot.TClient.Commands;
|
||||||
|
|
||||||
public interface IAuthorizedTelegramCommand : ITelegramCommand
|
public interface IAuthorizedTelegramCommand : ITelegramCommand
|
||||||
{
|
{
|
||||||
public Task ExecuteAsync(Update update, GetUserResponse user, CancellationToken ct);
|
/// <exception cref="UnauthorizedAccessException">
|
||||||
|
/// Throws if you try to use ITelegramCommand.ExecuteAsync
|
||||||
/// <exception cref="UnauthorizedAccessException">Throws if you try to use ITelegramCommand.ExecuteAsync
|
/// instead of IAuthorizedTelegramCommand.ExecuteAsync
|
||||||
/// instead of IAuthorizedTelegramCommand.ExecuteAsync</exception>
|
/// </exception>
|
||||||
Task ITelegramCommand.ExecuteAsync(Update update, CancellationToken ct)
|
Task ITelegramCommand.ExecuteAsync(Update update, CancellationToken ct)
|
||||||
{
|
{
|
||||||
throw new UnauthorizedAccessException("You do not have permission to access this command.");
|
throw new UnauthorizedAccessException("You do not have permission to access this command.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task ExecuteAsync(Update update, GetUserResponse user, CancellationToken ct);
|
||||||
}
|
}
|
||||||
@@ -5,10 +5,10 @@ using JOBot.TClient.Infrastructure.Attributes.Authorization;
|
|||||||
using JOBot.TClient.Infrastructure.Extensions;
|
using JOBot.TClient.Infrastructure.Extensions;
|
||||||
using JOBot.TClient.Services;
|
using JOBot.TClient.Services;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
|
|
||||||
namespace JOBot.TClient.Core.HostedServices;
|
namespace JOBot.TClient.Core.HostedServices;
|
||||||
|
|
||||||
@@ -22,8 +22,8 @@ public sealed class BotBackgroundService(
|
|||||||
protected override Task ExecuteAsync(CancellationToken stoppingToken)
|
protected override Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
{
|
{
|
||||||
botClient.StartReceiving(
|
botClient.StartReceiving(
|
||||||
updateHandler: HandleUpdateAsync,
|
HandleUpdateAsync,
|
||||||
errorHandler: HandleErrorAsync,
|
HandleErrorAsync,
|
||||||
cancellationToken: stoppingToken);
|
cancellationToken: stoppingToken);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
@@ -40,7 +40,7 @@ public sealed class BotBackgroundService(
|
|||||||
["/info"] = scope.ServiceProvider.GetRequiredService<InfoCommand>(),
|
["/info"] = scope.ServiceProvider.GetRequiredService<InfoCommand>(),
|
||||||
|
|
||||||
//Buttons
|
//Buttons
|
||||||
[ButtonResource.EULAAgrement] = scope.ServiceProvider.GetRequiredService<EulaAgreementButtonCommand>(),
|
[ButtonResource.EULAAgrement] = scope.ServiceProvider.GetRequiredService<EulaAgreementButtonCommand>()
|
||||||
};
|
};
|
||||||
|
|
||||||
if (update.Message is { Text: { } text, From: not null })
|
if (update.Message is { Text: { } text, From: not null })
|
||||||
@@ -69,12 +69,15 @@ public sealed class BotBackgroundService(
|
|||||||
|
|
||||||
await authorizedTelegramCommand.ExecuteAsync(update, user, ct);
|
await authorizedTelegramCommand.ExecuteAsync(update, user, ct);
|
||||||
}
|
}
|
||||||
else await command.ExecuteAsync(update, ct);
|
else
|
||||||
|
{
|
||||||
|
await command.ExecuteAsync(update, ct);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await bot.SendMessage(update.Message.From.Id, TextResource.CommandNotFound, cancellationToken: ct);
|
await bot.SendMessageRemK(update.Message.From.Id, TextResource.CommandNotFound, cancellationToken: ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
using Grpc.Core;
|
|
||||||
using Grpc.Net.Client;
|
|
||||||
using JOBot.Proto;
|
|
||||||
using JOBot.TClient.Commands.Buttons;
|
|
||||||
using JOBot.TClient.Commands.Commands;
|
|
||||||
using JOBot.TClient.Core.HostedServices;
|
|
||||||
using JOBot.TClient.Services;
|
|
||||||
using JOBot.TClient.Statements;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Telegram.Bot;
|
|
||||||
|
|
||||||
namespace JOBot.TClient;
|
|
||||||
|
|
||||||
public static class DependencyInjection
|
|
||||||
{
|
|
||||||
public static IServiceCollection ConfigureServices(this IServiceCollection services, IConfiguration config)
|
|
||||||
{
|
|
||||||
services.AddSingleton(config);
|
|
||||||
|
|
||||||
services.AddScoped<ChannelBase, GrpcChannel>(_ => GrpcChannel.ForAddress(config.GetValue<string>("BackendHost")
|
|
||||||
?? throw new MissingFieldException("Host is not defined")));
|
|
||||||
|
|
||||||
#region Commands
|
|
||||||
services.AddScoped<StartCommand>();
|
|
||||||
services.AddScoped<MenuCommand>();
|
|
||||||
services.AddScoped<InfoCommand>();
|
|
||||||
|
|
||||||
//buttons
|
|
||||||
services.AddScoped<EulaAgreementButtonCommand>();
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region gRPC Clients
|
|
||||||
services.AddGrpcClient<User.UserClient>(o => o.Address = new Uri("http://backend:5001"));
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Services
|
|
||||||
services.AddSingleton<UserService>();
|
|
||||||
services.AddScoped<PrepareUserService>();
|
|
||||||
services.AddScoped<MenuService>();
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region States
|
|
||||||
services.AddScoped<PrepareUserState>();
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// Bot service
|
|
||||||
services.AddHostedService<BotBackgroundService>();
|
|
||||||
services.AddSingleton<ITelegramBotClient>(_ =>
|
|
||||||
new TelegramBotClient(config.GetValue<string>("TelegramToken")
|
|
||||||
?? throw new MissingFieldException("TelegramToken is not set")));
|
|
||||||
|
|
||||||
services.AddLogging(builder => builder.AddConsole());
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
namespace JOBot.TClient.Infrastructure.Attributes.Authorization;
|
namespace JOBot.TClient.Infrastructure.Attributes.Authorization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Атрибут допуска к команде пользователя не завершившего стадию PrepareUser
|
||||||
|
/// </summary>
|
||||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
|
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
|
||||||
public class AcceptNotPreparedAttribute : Attribute;
|
public class AcceptNotPreparedAttribute : Attribute;
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using JOBot.TClient.Infrastructure.Extensions;
|
||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@ public class FallbackException : Exception
|
|||||||
{
|
{
|
||||||
public FallbackException(string message, Message botMessage, ITelegramBotClient botClient) : base(message)
|
public FallbackException(string message, Message botMessage, ITelegramBotClient botClient) : base(message)
|
||||||
{
|
{
|
||||||
botClient.SendMessage(chatId: botMessage.Chat.Id,
|
botClient.SendMessageRemK(botMessage.Chat.Id,
|
||||||
TextResource.FallbackMessage);
|
TextResource.FallbackMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,9 @@ namespace JOBot.TClient.Infrastructure.Extensions;
|
|||||||
|
|
||||||
public static class GRpcModelsExtensions
|
public static class GRpcModelsExtensions
|
||||||
{
|
{
|
||||||
public static bool IsPrepared(this GetUserResponse user) => user is { Eula: true, IsLogged: true } &&
|
public static bool IsPrepared(this GetUserResponse user)
|
||||||
|
{
|
||||||
|
return user is { Eula: true, IsLogged: true } &&
|
||||||
!string.IsNullOrEmpty(user.CVUrl);
|
!string.IsNullOrEmpty(user.CVUrl);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
using Telegram.Bot;
|
||||||
|
using Telegram.Bot.Types;
|
||||||
|
using Telegram.Bot.Types.Enums;
|
||||||
|
using Telegram.Bot.Types.ReplyMarkups;
|
||||||
|
|
||||||
|
namespace JOBot.TClient.Infrastructure.Extensions;
|
||||||
|
|
||||||
|
public static class TelegramBotClientExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Extension method for auto-remove of reply keyboard if is null
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bot"></param>
|
||||||
|
/// <param name="chatId"></param>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
/// <param name="parseMode"></param>
|
||||||
|
/// <param name="replyParameters"></param>
|
||||||
|
/// <param name="replyMarkup"></param>
|
||||||
|
/// <param name="linkPreviewOptions"></param>
|
||||||
|
/// <param name="messageThreadId"></param>
|
||||||
|
/// <param name="entities"></param>
|
||||||
|
/// <param name="disableNotification"></param>
|
||||||
|
/// <param name="protectContent"></param>
|
||||||
|
/// <param name="messageEffectId"></param>
|
||||||
|
/// <param name="businessConnectionId"></param>
|
||||||
|
/// <param name="allowPaidBroadcast"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Task<Message> SendMessageRemK(
|
||||||
|
this ITelegramBotClient bot,
|
||||||
|
ChatId chatId,
|
||||||
|
string text,
|
||||||
|
ParseMode parseMode = default,
|
||||||
|
ReplyParameters? replyParameters = null,
|
||||||
|
ReplyMarkup? replyMarkup = null,
|
||||||
|
LinkPreviewOptions? linkPreviewOptions = null,
|
||||||
|
int? messageThreadId = null,
|
||||||
|
IEnumerable<MessageEntity>? entities = null,
|
||||||
|
bool disableNotification = false,
|
||||||
|
bool protectContent = false,
|
||||||
|
string? messageEffectId = null,
|
||||||
|
string? businessConnectionId = null,
|
||||||
|
bool allowPaidBroadcast = false,
|
||||||
|
CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
replyMarkup ??= new ReplyKeyboardRemove();
|
||||||
|
|
||||||
|
return bot.SendMessage(chatId, text, parseMode, replyParameters, replyMarkup, linkPreviewOptions, messageThreadId,
|
||||||
|
entities, disableNotification, protectContent, messageEffectId, businessConnectionId, allowPaidBroadcast,
|
||||||
|
cancellationToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.4"/>
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.4"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.4"/>
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.4"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.4"/>
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.4"/>
|
||||||
|
<PackageReference Include="RabbitMQ.Client" Version="7.1.2"/>
|
||||||
<PackageReference Include="Telegram.Bot" Version="22.5.1"/>
|
<PackageReference Include="Telegram.Bot" Version="22.5.1"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@@ -31,6 +32,9 @@
|
|||||||
<None Update="appsettings.Example.json">
|
<None Update="appsettings.Example.json">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -58,9 +62,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="appsettings.json">
|
<ProjectReference Include="..\JOBot.Infrastructure\JOBot.Infrastructure.csproj" />
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ var host = Host.CreateDefaultBuilder(args)
|
|||||||
{
|
{
|
||||||
// Настройка DI
|
// Настройка DI
|
||||||
services.ConfigureServices(context.Configuration);
|
services.ConfigureServices(context.Configuration);
|
||||||
|
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|||||||
24
JOBot.TClient/Queues/AuthQueue.cs
Normal file
24
JOBot.TClient/Queues/AuthQueue.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System.Text;
|
||||||
|
using JOBot.Infrastructure.Config;
|
||||||
|
using JOBot.TClient.Services;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using RabbitMQ.Client;
|
||||||
|
using RabbitMQ.Client.Events;
|
||||||
|
|
||||||
|
namespace JOBot.TClient.Queues;
|
||||||
|
|
||||||
|
public class AuthQueue(IChannel channel, PrepareUserService prepareUserService) : BackgroundService
|
||||||
|
{
|
||||||
|
|
||||||
|
private async Task OnDataReceivedAsync(object sender, BasicDeliverEventArgs eventArgs)
|
||||||
|
{
|
||||||
|
await prepareUserService.AuthHookReceived(Convert.ToInt64(Encoding.UTF8.GetString(eventArgs.Body.ToArray())));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
|
{
|
||||||
|
var consumer = new AsyncEventingBasicConsumer(channel);
|
||||||
|
consumer.ReceivedAsync += OnDataReceivedAsync;
|
||||||
|
await channel.BasicConsumeAsync(RabbitQueues.AuthQueue, autoAck: true, consumer: consumer, cancellationToken: stoppingToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
using JOBot.TClient.Infrastructure.Extensions;
|
||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using User = JOBot.Proto.User;
|
|
||||||
|
|
||||||
namespace JOBot.TClient.Services;
|
namespace JOBot.TClient.Services;
|
||||||
|
|
||||||
@@ -10,6 +10,6 @@ public class MenuService(ITelegramBotClient bot)
|
|||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
||||||
|
|
||||||
await bot.SendMessage(update.Message.From.Id,"PrepareUser stage is done.", cancellationToken: ct);
|
await bot.SendMessageRemK(update.Message.From.Id, "PrepareUser stage is done.", cancellationToken: ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using JOBot.Proto;
|
using JOBot.Proto;
|
||||||
using JOBot.TClient.Infrastructure.Exceptions;
|
using JOBot.TClient.Infrastructure.Exceptions;
|
||||||
|
using JOBot.TClient.Infrastructure.Extensions;
|
||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using User = JOBot.Proto.User;
|
using User = JOBot.Proto.User;
|
||||||
@@ -18,7 +19,7 @@ public class PrepareUserService(ITelegramBotClient bot, User.UserClient userClie
|
|||||||
/// <param name="ct">Cancellation Token</param>
|
/// <param name="ct">Cancellation Token</param>
|
||||||
/// <returns>RPC User Response</returns>
|
/// <returns>RPC User Response</returns>
|
||||||
/// <exception cref="FallbackException">If something in server logic went wrong</exception>
|
/// <exception cref="FallbackException">If something in server logic went wrong</exception>
|
||||||
/// <exception cref="ArgumentNullException">If update.Message is null</exception>
|
/// <exception cref="ArgumentNullException">update.Message is null</exception>
|
||||||
public async Task<GetUserResponse> RegisterUser(Update update, CancellationToken ct = default)
|
public async Task<GetUserResponse> RegisterUser(Update update, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
||||||
@@ -26,21 +27,21 @@ public class PrepareUserService(ITelegramBotClient bot, User.UserClient userClie
|
|||||||
var result = await _userClient.RegisterAsync(new RegisterRequest
|
var result = await _userClient.RegisterAsync(new RegisterRequest
|
||||||
{
|
{
|
||||||
UserId = update.Message.From.Id,
|
UserId = update.Message.From.Id,
|
||||||
Username = update.Message.From.Username,
|
Username = update.Message.From.Username
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!result.Success)
|
if (!result.Success)
|
||||||
{
|
{
|
||||||
await _bot.SendMessage(chatId: update.Message.Chat.Id,
|
await _bot.SendMessageRemK(update.Message.Chat.Id,
|
||||||
TextResource.FallbackMessage,
|
TextResource.FallbackMessage,
|
||||||
cancellationToken: ct);
|
cancellationToken: ct);
|
||||||
|
|
||||||
throw new FallbackException(TextResource.FallbackMessage, update.Message, _bot);
|
throw new FallbackException(TextResource.FallbackMessage, update.Message, _bot);
|
||||||
}
|
}
|
||||||
|
|
||||||
var user = await _userClient.GetUserAsync(new GetUserRequest()
|
var user = await _userClient.GetUserAsync(new GetUserRequest
|
||||||
{
|
{
|
||||||
UserId = update.Message.From.Id,
|
UserId = update.Message.From.Id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
@@ -54,12 +55,12 @@ public class PrepareUserService(ITelegramBotClient bot, User.UserClient userClie
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="update">Telegram Update object</param>
|
/// <param name="update">Telegram Update object</param>
|
||||||
/// <param name="ct">Cancellation Token</param>
|
/// <param name="ct">Cancellation Token</param>
|
||||||
/// <exception cref="ArgumentNullException">If update.Message is null</exception>
|
/// <exception cref="ArgumentNullException">update.Message is null</exception>
|
||||||
public async Task AskForEulaAgreement(Update update, CancellationToken ct = default)
|
public async Task AskForEulaAgreement(Update update, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
||||||
|
|
||||||
await _bot.SendMessage(
|
await _bot.SendMessageRemK(
|
||||||
update.Message.From.Id,
|
update.Message.From.Id,
|
||||||
TextResource.EULA,
|
TextResource.EULA,
|
||||||
replyMarkup: new[] { ButtonResource.EULAAgrement }, cancellationToken: ct);
|
replyMarkup: new[] { ButtonResource.EULAAgrement }, cancellationToken: ct);
|
||||||
@@ -74,10 +75,10 @@ public class PrepareUserService(ITelegramBotClient bot, User.UserClient userClie
|
|||||||
public async Task AcceptEula(Update update, CancellationToken ct = default)
|
public async Task AcceptEula(Update update, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
||||||
var result = await _userClient.AcceptEulaAsync(new()
|
var result = await _userClient.AcceptEulaAsync(new AcceptEulaRequest
|
||||||
{
|
{
|
||||||
EulaAccepted = true,
|
EulaAccepted = true,
|
||||||
UserId = update.Message.From.Id,
|
UserId = update.Message.From.Id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!result.Success)
|
if (!result.Success)
|
||||||
@@ -88,14 +89,33 @@ public class PrepareUserService(ITelegramBotClient bot, User.UserClient userClie
|
|||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
||||||
|
|
||||||
var url = await _userClient.GetHeadHunterAuthHookAsync(new GetHeadHunterAuthHookRequest()
|
var url = await _userClient.GetHeadHunterAuthHookAsync(new GetHeadHunterAuthHookRequest
|
||||||
{
|
{
|
||||||
UserId = update.Message.From.Id
|
UserId = update.Message.From.Id
|
||||||
});
|
});
|
||||||
|
|
||||||
await _bot.SendMessage(
|
await _bot.SendMessageRemK(
|
||||||
update.Message.From.Id,
|
update.Message.From.Id,
|
||||||
string.Format(TextResource.AskForAuth, [url.RegistrationUrl]),
|
string.Format(TextResource.AskForAuth, [url.RegistrationUrl]),
|
||||||
cancellationToken: ct);
|
cancellationToken: ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task AuthHookReceived(long userId, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
await _bot.SendMessageRemK(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SelectCv(long userId, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
await _bot.SendMessageRemK(userId, "Давайте выберем одно из доступных резюме:",
|
||||||
|
cancellationToken: ct); //TODO: https://git.lisoveliy.su/Lisoveliy/JOBot/issues/9
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ public class UserService(ITelegramBotClient bot, User.UserClient userClient)
|
|||||||
{
|
{
|
||||||
user = await userClient.GetUserAsync(new GetUserRequest() //Получаем пользователя
|
user = await userClient.GetUserAsync(new GetUserRequest() //Получаем пользователя
|
||||||
{
|
{
|
||||||
UserId = update.Message.From.Id,
|
UserId = update.Message.From.Id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (RpcException e) //Пользователь не найден?
|
catch (RpcException e) //Пользователь не найден?
|
||||||
@@ -36,6 +36,7 @@ public class UserService(ITelegramBotClient bot, User.UserClient userClient)
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
87
JOBot.TClient/Startup.cs
Normal file
87
JOBot.TClient/Startup.cs
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
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 Startup
|
||||||
|
{
|
||||||
|
public static IServiceCollection ConfigureServices(this IServiceCollection services, IConfiguration config)
|
||||||
|
{
|
||||||
|
services.AddSingleton(config);
|
||||||
|
|
||||||
|
services.AddSingleton(_ => GrpcChannel.ForAddress(config.GetValue<string>("BackendHost")
|
||||||
|
?? throw new MissingFieldException("Host is not defined")));
|
||||||
|
|
||||||
|
#region Commands
|
||||||
|
|
||||||
|
services.AddSingleton<StartCommand>();
|
||||||
|
services.AddSingleton<MenuCommand>();
|
||||||
|
services.AddSingleton<InfoCommand>();
|
||||||
|
|
||||||
|
//buttons
|
||||||
|
services.AddSingleton<EulaAgreementButtonCommand>();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region gRPC Clients
|
||||||
|
|
||||||
|
services.AddGrpcClient<User.UserClient>(o => o.Address = new Uri("http://backend:5001"));
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Services
|
||||||
|
|
||||||
|
services.AddSingleton<UserService>();
|
||||||
|
services.AddSingleton<PrepareUserService>();
|
||||||
|
services.AddSingleton<MenuService>();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region States
|
||||||
|
|
||||||
|
services.AddSingleton<PrepareUserState>();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region RabbitMQ Clients
|
||||||
|
|
||||||
|
var factory = new ConnectionFactory { HostName = "rabbitmq" };
|
||||||
|
var connection = factory.CreateConnectionAsync().Result;
|
||||||
|
var channel = connection.CreateChannelAsync().Result;
|
||||||
|
|
||||||
|
channel.QueueDeclareAsync(
|
||||||
|
RabbitQueues.AuthQueue,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
arguments: null).Wait();
|
||||||
|
|
||||||
|
services.AddSingleton(channel);
|
||||||
|
services.AddHostedService<AuthQueue>();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// Bot service
|
||||||
|
services.AddHostedService<BotBackgroundService>();
|
||||||
|
services.AddSingleton<ITelegramBotClient>(_ =>
|
||||||
|
new TelegramBotClient(config.GetValue<string>("TelegramToken")
|
||||||
|
?? throw new MissingFieldException("TelegramToken is not set")));
|
||||||
|
|
||||||
|
services.AddLogging(builder => builder.AddConsole());
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
using JOBot.Proto;
|
using JOBot.Proto;
|
||||||
using JOBot.TClient.Services;
|
using JOBot.TClient.Services;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using User = JOBot.Proto.User;
|
|
||||||
|
|
||||||
namespace JOBot.TClient.Statements;
|
namespace JOBot.TClient.Statements;
|
||||||
|
|
||||||
@@ -33,12 +32,12 @@ public class PrepareUserState(PrepareUserService prepareUserService, MenuService
|
|||||||
/// <param name="ct"></param>
|
/// <param name="ct"></param>
|
||||||
public async Task AcceptEula(GetUserResponse user, Update update, CancellationToken ct = default)
|
public async Task AcceptEula(GetUserResponse user, Update update, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
await prepareUserService.AcceptEula(update, ct: ct);
|
await prepareUserService.AcceptEula(update, ct);
|
||||||
await OnUserEulaValidStage(user, update, ct);
|
await OnUserEulaValidStage(user, update, ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Continue prepare stage
|
/// Check user logged
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="user"></param>
|
/// <param name="user"></param>
|
||||||
/// <param name="update"></param>
|
/// <param name="update"></param>
|
||||||
@@ -50,6 +49,19 @@ public class PrepareUserState(PrepareUserService prepareUserService, MenuService
|
|||||||
await prepareUserService.Auth(update, ct);
|
await prepareUserService.Auth(update, ct);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await OnAuthStage(user, update, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check user selected CV
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user"></param>
|
||||||
|
/// <param name="update"></param>
|
||||||
|
/// <param name="ct"></param>
|
||||||
|
private async Task OnAuthStage(GetUserResponse user, Update update, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(user.CVUrl)) await prepareUserService.SelectCv(update, ct);
|
||||||
await menuService.RenderMenu(update, ct); //boilerplate
|
await menuService.RenderMenu(update, ct); //boilerplate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<root>
|
<root>
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root"
|
||||||
|
xmlns="">
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
@@ -13,10 +14,14 @@
|
|||||||
<value>1.3</value>
|
<value>1.3</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<resheader name="reader">
|
<resheader name="reader">
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||||
|
PublicKeyToken=b77a5c561934e089
|
||||||
|
</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||||
|
PublicKeyToken=b77a5c561934e089
|
||||||
|
</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<data name="EULA" xml:space="preserve">
|
<data name="EULA" xml:space="preserve">
|
||||||
<value>Продолжая, вы принимаете политику конфиденциальности и правила сервиса
|
<value>Продолжая, вы принимаете политику конфиденциальности и правила сервиса
|
||||||
|
|||||||
14
JOBot.sln
14
JOBot.sln
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JOBot.Backend", "JOBot.Back
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JOBot.TClient", "JOBot.TClient\JOBot.TClient.csproj", "{4526BCB1-DAD3-430C-BD7C-9C114DFE9A2A}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JOBot.TClient", "JOBot.TClient\JOBot.TClient.csproj", "{4526BCB1-DAD3-430C-BD7C-9C114DFE9A2A}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JOBot.Infrastructure", "JOBot.Infrastructure\JOBot.Infrastructure.csproj", "{32006B71-E6F7-4264-A8B4-AC3A6B77CC54}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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|x64.Build.0 = Release|Any CPU
|
||||||
{4526BCB1-DAD3-430C-BD7C-9C114DFE9A2A}.Release|x86.ActiveCfg = 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
|
{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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
30
Proto/resume.proto
Normal file
30
Proto/resume.proto
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
option csharp_namespace = "JOBot.Proto";
|
||||||
|
|
||||||
|
import "google/protobuf/wrappers.proto";
|
||||||
|
|
||||||
|
service Resume{
|
||||||
|
rpc GetResume(GetResumeRequest) returns (GetResumeResponse);
|
||||||
|
rpc GetAvailable(GetAvailableRequest) returns (GetAvailableResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetResumeRequest{
|
||||||
|
int64 user_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetResumeResponse{
|
||||||
|
google.protobuf.StringValue resumeUrl = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetAvailableRequest{
|
||||||
|
int64 user_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetAvailableResponse{
|
||||||
|
repeated ResumeDesc resumes = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ResumeDesc{
|
||||||
|
string resumeUrl = 1;
|
||||||
|
string name = 2;
|
||||||
|
}
|
||||||
10
README.md
10
README.md
@@ -31,21 +31,25 @@ Telegram-бот для автоматизации поиска работы че
|
|||||||
## 🚀 Запуск
|
## 🚀 Запуск
|
||||||
|
|
||||||
### Требования
|
### Требования
|
||||||
|
|
||||||
- .NET 8 SDK
|
- .NET 8 SDK
|
||||||
- Docker (для работы с БД)
|
- Docker (для работы с БД)
|
||||||
- Аккаунт разработчика на [dev.hh.ru](https://dev.hh.ru)
|
- Аккаунт разработчика на [dev.hh.ru](https://dev.hh.ru)
|
||||||
|
|
||||||
### 1. Настройка конфигурации
|
### 1. Настройка конфигурации
|
||||||
|
|
||||||
Создайте `appsettings.json` в `JOBot.TClient` на основе `appsettings.Example.json`
|
Создайте `appsettings.json` в `JOBot.TClient` на основе `appsettings.Example.json`
|
||||||
|
|
||||||
### 2. Запуск через Docker
|
### 2. Запуск через Docker
|
||||||
|
|
||||||
```
|
```
|
||||||
docker-compose up -d --build
|
docker-compose up -d --build
|
||||||
```
|
```
|
||||||
|
|
||||||
## 📌 Команды бота
|
## 📌 Команды бота
|
||||||
|
|
||||||
| Команда | Описание |
|
| Команда | Описание |
|
||||||
|-------|--------|
|
|---------|----------------------------------------------|
|
||||||
| /start | Начало работы |
|
| /start | Начало работы |
|
||||||
| /menu | Настройка откликов и резюме по предпочтениям |
|
| /menu | Настройка откликов и резюме по предпочтениям |
|
||||||
| /info | Информация о боте |
|
| /info | Информация о боте |
|
||||||
@@ -55,6 +59,8 @@ MIT License. Подробнее в файле LICENSE.
|
|||||||
|
|
||||||
## Отказ от ответственности
|
## Отказ от ответственности
|
||||||
|
|
||||||
Продолжая, вы принимаете [политику конфиденциальности](https://hh.ru/article/personal_data?backurl=%2F&role=applicant) и [правила сервиса](https://hh.ru/account/agreement?backurl=%2Faccount%2Fsignup%3Fbackurl%3D%252F%26role%3Dapplicant&role=applicant) hh.ru
|
Продолжая, вы принимаете [политику конфиденциальности](https://hh.ru/article/personal_data?backurl=%2F&role=applicant)
|
||||||
|
и [правила сервиса](https://hh.ru/account/agreement?backurl=%2Faccount%2Fsignup%3Fbackurl%3D%252F%26role%3Dapplicant&role=applicant)
|
||||||
|
hh.ru
|
||||||
|
|
||||||
Этот сервис никак не связан с HeadHunter™ (далее hh.ru), не выдаёт себя за hh.ru и не является hh.ru
|
Этот сервис никак не связан с HeadHunter™ (далее hh.ru), не выдаёт себя за hh.ru и не является hh.ru
|
||||||
@@ -1,6 +1,17 @@
|
|||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
rabbitmq:
|
||||||
|
hostname: jobot-rabbit
|
||||||
|
image: rabbitmq:4
|
||||||
|
ports:
|
||||||
|
- "5672:5672"
|
||||||
|
- "15672:15672"
|
||||||
|
volumes:
|
||||||
|
- rabbitmq_data:/var/lib/rabbitmq/
|
||||||
|
networks:
|
||||||
|
- jobot
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:15
|
image: postgres:15
|
||||||
environment:
|
environment:
|
||||||
@@ -9,7 +20,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- ./.docker/postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
networks:
|
networks:
|
||||||
- jobot
|
- jobot
|
||||||
|
|
||||||
@@ -19,6 +30,7 @@ services:
|
|||||||
dockerfile: JOBot.Backend/Dockerfile
|
dockerfile: JOBot.Backend/Dockerfile
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
|
- rabbitmq
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "5000:5000"
|
||||||
- "5001:5001"
|
- "5001:5001"
|
||||||
@@ -36,3 +48,7 @@ services:
|
|||||||
|
|
||||||
networks:
|
networks:
|
||||||
jobot:
|
jobot:
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres_data:
|
||||||
|
rabbitmq_data:
|
||||||
16
compose.yml
16
compose.yml
@@ -1,13 +1,21 @@
|
|||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
rabbitmq:
|
||||||
|
hostname: jobot-rabbit
|
||||||
|
image: rabbitmq:4
|
||||||
|
volumes:
|
||||||
|
- rabbitmq_data:/var/lib/rabbitmq/
|
||||||
|
networks:
|
||||||
|
- jobot
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:15
|
image: postgres:15
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_PASSWORD: LocalDbPass
|
POSTGRES_PASSWORD: LocalDbPass
|
||||||
POSTGRES_DB: jobot
|
POSTGRES_DB: jobot
|
||||||
volumes:
|
volumes:
|
||||||
- ./.docker/postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
networks:
|
networks:
|
||||||
- jobot
|
- jobot
|
||||||
|
|
||||||
@@ -17,6 +25,7 @@ services:
|
|||||||
dockerfile: JOBot.Backend/Dockerfile
|
dockerfile: JOBot.Backend/Dockerfile
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
|
- rabbitmq
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "5000:5000"
|
||||||
networks:
|
networks:
|
||||||
@@ -33,3 +42,8 @@ services:
|
|||||||
|
|
||||||
networks:
|
networks:
|
||||||
jobot:
|
jobot:
|
||||||
|
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres_data:
|
||||||
|
rabbitmq_data:
|
||||||
Reference in New Issue
Block a user