Compare commits
17 Commits
ace122dbbd
...
399364f5fc
Author | SHA1 | Date | |
---|---|---|---|
399364f5fc | |||
4bc1e63da7 | |||
6e16c5831e | |||
a526dbf6c6 | |||
67a3457f2d | |||
ac39117cf4 | |||
5b4d524c47 | |||
4a7810f571 | |||
252adf0fc7 | |||
90df00d88d | |||
f68f29088b | |||
6764c02b53 | |||
0c47806c0d | |||
9f65685ee0 | |||
e5cfc12786 | |||
9369f0a0ff | |||
4cc09025fe |
2
.gitignore
vendored
2
.gitignore
vendored
@ -405,3 +405,5 @@ FodyWeavers.xsd
|
||||
|
||||
# Secrets
|
||||
JOBot.TClient/appsettings.json
|
||||
/.idea/.idea.JOBot/Docker/compose.generated.override.yml
|
||||
/.idea/.idea.JOBot/Docker/compose.dev.generated.override.yml
|
||||
|
@ -1,19 +1,17 @@
|
||||
namespace JOBot.Backend.DAL.Context;
|
||||
|
||||
using JOBot.Backend.DAL.Models;
|
||||
using Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
public class AppDbContext : DbContext
|
||||
public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
|
||||
{
|
||||
public DbSet<User> Users { get; set; }
|
||||
|
||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.Entity<User>()
|
||||
.HasAlternateKey(b => b.TelegramId);
|
||||
.HasAlternateKey(b => b.UserId);
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using JOBot.Proto;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace JOBot.Backend.DAL.Models;
|
||||
@ -9,10 +10,30 @@ public class User
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[Key]
|
||||
public required long TelegramId { get; set; }
|
||||
[MaxLength(50)]
|
||||
public required long UserId { get; set; }
|
||||
[MaxLength(255)]
|
||||
public string? Username { get; set; }
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public string? HeadHunterResumeUrl { get; set; }
|
||||
[MaxLength(255)] public string? AccessToken { get; set; } = null;
|
||||
[MaxLength(255)] public string? RefreshToken { get; set; } = null;
|
||||
|
||||
public bool Eula { get; set; } = false;
|
||||
[MaxLength(255)] public string? CvUrl { get; set; } = null;
|
||||
}
|
||||
|
||||
//TODO: Негоже это маппинги в DAL ложить
|
||||
public static class UserMap
|
||||
{
|
||||
public static GetUserResponse MapToResponse(this User user)
|
||||
{
|
||||
return new GetUserResponse
|
||||
{
|
||||
UserId = user.UserId,
|
||||
Username = user.Username,
|
||||
Eula = user.Eula,
|
||||
IsLogged = user.RefreshToken != null,
|
||||
CVUrl = user.CvUrl
|
||||
};
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using JOBot.Backend.DAL.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace JOBot.Backend.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20250501164641_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("JOBot.Backend.DAL.Models.User", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<long>("TelegramId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasAlternateKey("TelegramId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using JOBot.Backend.DAL.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace JOBot.Backend.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20250501165245_UpdateUser")]
|
||||
partial class UpdateUser
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("JOBot.Backend.DAL.Models.User", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<long>("TelegramId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasAlternateKey("TelegramId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace JOBot.Backend.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class UpdateUser : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CreatedAt",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Username",
|
||||
table: "Users",
|
||||
type: "character varying(50)",
|
||||
maxLength: 50,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "text",
|
||||
oldNullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Username",
|
||||
table: "Users",
|
||||
type: "text",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "character varying(50)",
|
||||
oldMaxLength: 50,
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "CreatedAt",
|
||||
table: "Users",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace JOBot.Backend.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddTimeStamp : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "CreatedAt",
|
||||
table: "Users",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CreatedAt",
|
||||
table: "Users");
|
||||
}
|
||||
}
|
||||
}
|
@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace JOBot.Backend.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20250501165633_AddTimeStamp")]
|
||||
partial class AddTimeStamp
|
||||
[Migration("20250710203327_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -31,19 +31,34 @@ namespace JOBot.Backend.Data.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("AccessToken")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<long>("TelegramId")
|
||||
b.Property<string>("CvUrl")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b.Property<bool>("Eula")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("RefreshToken")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b.Property<long>("UserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)");
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasAlternateKey("TelegramId");
|
||||
b.HasAlternateKey("UserId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
namespace JOBot.Backend.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
@ -16,14 +16,18 @@ namespace JOBot.Backend.Data.Migrations
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
TelegramId = table.Column<long>(type: "bigint", nullable: false),
|
||||
Username = table.Column<string>(type: "text", nullable: true),
|
||||
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
UserId = table.Column<long>(type: "bigint", nullable: false),
|
||||
Username = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
||||
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
AccessToken = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
||||
RefreshToken = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
||||
Eula = table.Column<bool>(type: "boolean", nullable: false),
|
||||
CvUrl = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Users", x => x.Id);
|
||||
table.UniqueConstraint("AK_Users_TelegramId", x => x.TelegramId);
|
||||
table.UniqueConstraint("AK_Users_UserId", x => x.UserId);
|
||||
});
|
||||
}
|
||||
|
@ -28,19 +28,34 @@ namespace JOBot.Backend.Data.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("AccessToken")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<long>("TelegramId")
|
||||
b.Property<string>("CvUrl")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b.Property<bool>("Eula")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("RefreshToken")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b.Property<long>("UserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)");
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasAlternateKey("TelegramId");
|
||||
b.HasAlternateKey("UserId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
@ -8,4 +8,7 @@ RUN dotnet publish "JOBot.Backend/JOBot.Backend.csproj" -c Release -o /app
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0
|
||||
WORKDIR /app
|
||||
COPY --from=build /app .
|
||||
EXPOSE 5001
|
||||
EXPOSE 5000
|
||||
ENV ASPNETCORE_ENVIRONMENT Staging
|
||||
ENTRYPOINT ["dotnet", "JOBot.Backend.dll"]
|
@ -9,6 +9,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.30.2" />
|
||||
<PackageReference Include="Grpc.AspNetCore" Version="2.71.0" />
|
||||
<PackageReference Include="Grpc.AspNetCore.Server.Reflection" Version="2.71.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.71.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
@ -24,4 +25,8 @@
|
||||
<Protobuf Include="..\Proto\*" GrpcServices="Server"></Protobuf>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Data\Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,4 +1,4 @@
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using JOBot.Backend;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
@ -1,43 +1,75 @@
|
||||
using Grpc.Core;
|
||||
using JOBot.Proto;
|
||||
using JOBot.Backend.DAL.Context;
|
||||
|
||||
using Models = JOBot.Backend.DAL.Models;
|
||||
using JOBot.Backend.DAL.Models;
|
||||
using JOBot.Proto;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using User = JOBot.Backend.DAL.Models.User;
|
||||
|
||||
namespace JOBot.Backend.Services.gRPC;
|
||||
public class UserService(AppDbContext dbContext) : User.UserBase
|
||||
|
||||
public class UserService(AppDbContext dbContext) : Proto.User.UserBase
|
||||
{
|
||||
|
||||
public override Task<RegisterResponse> Register(
|
||||
RegisterRequest request,
|
||||
ServerCallContext context)
|
||||
/// <summary>
|
||||
/// Create user
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="_"></param>
|
||||
/// <returns>Status of operation (fail if user exists)</returns>
|
||||
public override async Task<RegisterResponse> Register(RegisterRequest request, ServerCallContext _)
|
||||
{
|
||||
if(!dbContext.Users
|
||||
.Any(x => x.TelegramId == request.UserId))
|
||||
{
|
||||
dbContext.Users.Add(new Models.User
|
||||
{
|
||||
TelegramId = request.UserId,
|
||||
Username = !string.IsNullOrEmpty(request.Username) ? request.Username : null
|
||||
});
|
||||
if (await dbContext.Users.AnyAsync(x => x.UserId == request.UserId))
|
||||
return new RegisterResponse { Success = false };
|
||||
|
||||
dbContext.SaveChanges();
|
||||
return Task.FromResult(new RegisterResponse
|
||||
{
|
||||
Success = true
|
||||
});
|
||||
}
|
||||
|
||||
return Task.FromResult(new RegisterResponse
|
||||
dbContext.Users.Add(new User
|
||||
{
|
||||
Success = false
|
||||
UserId = request.UserId,
|
||||
Username = !string.IsNullOrEmpty(request.Username) ? request.Username : null
|
||||
});
|
||||
await dbContext.SaveChangesAsync();
|
||||
|
||||
return new RegisterResponse { Success = true };
|
||||
}
|
||||
|
||||
public override Task<GetUserResponse> GetUser(
|
||||
GetUserRequest request,
|
||||
ServerCallContext context)
|
||||
/// <summary>
|
||||
/// Get user for client
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="_"></param>
|
||||
/// <returns>User, or throws RPC exception if not found</returns>
|
||||
public override async Task<GetUserResponse> GetUser(GetUserRequest request, ServerCallContext _)
|
||||
{
|
||||
return null;
|
||||
var user = await dbContext.Users.FirstOrDefaultAsync(x => x.UserId == request.UserId);
|
||||
ThrowIfUserNotFound(user);
|
||||
|
||||
return user!.MapToResponse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Accept EULA for user
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="_"></param>
|
||||
/// <returns>Status of operation</returns>
|
||||
public override async Task<AcceptEulaResponse> AcceptEula(AcceptEulaRequest request, ServerCallContext _)
|
||||
{
|
||||
var user = await dbContext.Users.FirstOrDefaultAsync(x => x.UserId == request.UserId);
|
||||
if (user == null)
|
||||
return new AcceptEulaResponse { Success = false };
|
||||
|
||||
user.Eula = request.EulaAccepted;
|
||||
await dbContext.SaveChangesAsync();
|
||||
|
||||
return new AcceptEulaResponse { Success = true };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throw RPCException if user not found
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <exception cref="RpcException"></exception>
|
||||
private static void ThrowIfUserNotFound(User? user)
|
||||
{
|
||||
if (user == null)
|
||||
throw new RpcException(new Status(StatusCode.NotFound, "User not found"));
|
||||
}
|
||||
}
|
@ -2,6 +2,8 @@ using JOBot.Backend.DAL.Context;
|
||||
using JOBot.Backend.Services.gRPC;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace JOBot.Backend;
|
||||
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
@ -14,12 +16,15 @@ public class Startup
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddGrpc();
|
||||
services.AddGrpcReflection();
|
||||
|
||||
services.AddDbContext<AppDbContext>(options =>
|
||||
options.UseNpgsql(Configuration.GetConnectionString("PostgreSQL")));
|
||||
}
|
||||
|
||||
public void Configure(WebApplication app, IWebHostEnvironment env)
|
||||
{
|
||||
app.MapGrpcReflectionService().AllowAnonymous();
|
||||
app.MapGrpcService<UserService>();
|
||||
}
|
||||
}
|
@ -4,5 +4,8 @@
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"PostgreSQL": "Host=localhost;Port=5432;Database=jobot;Username=postgres;Password=LocalDbPass"
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,6 @@
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"PostgreSQL": "Host=localhost;Port=5432;Database=jobot_test;Username=postgres;Password=LocalDbPass"
|
||||
"PostgreSQL": "Host=postgres;Port=5432;Database=jobot_test;Username=postgres;Password=LocalDbPass"
|
||||
}
|
||||
}
|
@ -7,13 +7,17 @@
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"PostgreSQL": "Host=localhost;Port=5432;Database=jobot;Username=postgres;Password=LocalDbPass"
|
||||
"PostgreSQL": "Host=postgres;Port=5432;Database=jobot;Username=postgres;Password=LocalDbPass"
|
||||
},
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
"Http": {
|
||||
"Url": "http://localhost:5001",
|
||||
"gRPC": {
|
||||
"Url": "http://*:5001",
|
||||
"Protocols": "Http2"
|
||||
},
|
||||
"REST": {
|
||||
"Url": "http://*:5000",
|
||||
"Protocols": "Http1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
71
JOBot.TClient/ButtonResource.Designer.cs
generated
Normal file
71
JOBot.TClient/ButtonResource.Designer.cs
generated
Normal file
@ -0,0 +1,71 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace JOBot.TClient {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class ButtonResource {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal ButtonResource() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("JOBot.TClient.ButtonResource", typeof(ButtonResource).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Соглашаюсь с условиями использования ✅.
|
||||
/// </summary>
|
||||
public static string EULAAgrement {
|
||||
get {
|
||||
return ResourceManager.GetString("EULAAgrement", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
24
JOBot.TClient/ButtonResource.resx
Normal file
24
JOBot.TClient/ButtonResource.resx
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="EULAAgrement" xml:space="preserve">
|
||||
<value>Соглашаюсь с условиями использования ✅</value>
|
||||
</data>
|
||||
</root>
|
17
JOBot.TClient/Commands/Buttons/EulaAgreementButtonCommand.cs
Normal file
17
JOBot.TClient/Commands/Buttons/EulaAgreementButtonCommand.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using JOBot.Proto;
|
||||
using JOBot.TClient.Infrastructure.Attributes.Authorization;
|
||||
using JOBot.TClient.Services;
|
||||
using JOBot.TClient.Statements;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
|
||||
namespace JOBot.TClient.Commands.Buttons;
|
||||
|
||||
[AcceptNotPrepared]
|
||||
public class EulaAgreementButtonCommand(PrepareUserState prepareUserState) : IAuthorizedTelegramCommand
|
||||
{
|
||||
public async Task ExecuteAsync(Update update, GetUserResponse user, CancellationToken ct)
|
||||
{
|
||||
await prepareUserState.AcceptEula(update, ct);
|
||||
}
|
||||
}
|
14
JOBot.TClient/Commands/Commands/InfoCommand.cs
Normal file
14
JOBot.TClient/Commands/Commands/InfoCommand.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace JOBot.TClient.Commands.Commands;
|
||||
|
||||
public class InfoCommand(ITelegramBotClient bot) : ITelegramCommand
|
||||
{
|
||||
public async Task ExecuteAsync(Update update, CancellationToken ct)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
||||
|
||||
await bot.SendMessage(update.Message.From.Id, TextResource.Info, cancellationToken: ct);
|
||||
}
|
||||
}
|
13
JOBot.TClient/Commands/Commands/MenuCommand.cs
Normal file
13
JOBot.TClient/Commands/Commands/MenuCommand.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using JOBot.Proto;
|
||||
using JOBot.TClient.Services;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace JOBot.TClient.Commands.Commands;
|
||||
|
||||
public class MenuCommand(MenuService menuService) : IAuthorizedTelegramCommand
|
||||
{
|
||||
public async Task ExecuteAsync(Update update, GetUserResponse user, CancellationToken ct)
|
||||
{
|
||||
await menuService.RenderMenu(update, ct);
|
||||
}
|
||||
}
|
12
JOBot.TClient/Commands/Commands/StartCommand.cs
Normal file
12
JOBot.TClient/Commands/Commands/StartCommand.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using JOBot.TClient.Statements;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace JOBot.TClient.Commands.Commands;
|
||||
|
||||
public class StartCommand(PrepareUserState prepareUserState) : ITelegramCommand
|
||||
{
|
||||
public async Task ExecuteAsync(Update update, CancellationToken ct)
|
||||
{
|
||||
await prepareUserState.TryToPrepareUser(update, ct);
|
||||
}
|
||||
}
|
17
JOBot.TClient/Commands/IAuthorizedTelegramCommand.cs
Normal file
17
JOBot.TClient/Commands/IAuthorizedTelegramCommand.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using JOBot.Proto;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace JOBot.TClient.Commands;
|
||||
|
||||
public interface IAuthorizedTelegramCommand : ITelegramCommand
|
||||
{
|
||||
public Task ExecuteAsync(Update update, GetUserResponse user, CancellationToken ct);
|
||||
|
||||
/// <exception cref="UnauthorizedAccessException">Throws if you try to use ITelegramCommand.ExecuteAsync
|
||||
/// instead of IAuthorizedTelegramCommand.ExecuteAsync</exception>
|
||||
Task ITelegramCommand.ExecuteAsync(Update update, CancellationToken ct)
|
||||
{
|
||||
throw new UnauthorizedAccessException("You do not have permission to access this command.");
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using JOBot.TClient.Core.Services;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace JOBot.TClient.Commands;
|
||||
|
||||
public class StartCommand(ITelegramBotClient bot, UserService userService) : ITelegramCommand
|
||||
{
|
||||
private const string ReturnMessage = "Привет! Я JOBot, помощник по поиску работы в IT.";
|
||||
public async Task ExecuteAsync(Update update, CancellationToken ct)
|
||||
{
|
||||
await userService.RegisterAsync(
|
||||
update.Message!.Chat.Id,
|
||||
update.Message.Chat.Username);
|
||||
|
||||
await bot.SendMessage(chatId: update.Message.Chat.Id,
|
||||
"Продолжая, вы принимаете политику конфиденциальности и правила сервиса" +
|
||||
"\nhttps://hh.ru/article/personal_data?backurl=%2F&role=applicant" +
|
||||
"\nhttps://hh.ru/account/agreement?backurl=%2Faccount%2Fsignup%3Fbackurl%3D%252F%26role%3Dapplicant&role=applicant",
|
||||
cancellationToken: ct);
|
||||
}
|
||||
}
|
@ -1,17 +1,22 @@
|
||||
using JOBot.TClient.Commands;
|
||||
using JOBot.TClient.Commands.Buttons;
|
||||
using JOBot.TClient.Commands.Commands;
|
||||
using JOBot.TClient.Infrastructure.Attributes.Authorization;
|
||||
using JOBot.TClient.Infrastructure.Extensions;
|
||||
using JOBot.TClient.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JOBot.TClient.Core.HostedServices;
|
||||
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace JOBot.TClient.Core.HostedServices;
|
||||
|
||||
public sealed class BotBackgroundService(
|
||||
ITelegramBotClient botClient,
|
||||
IServiceProvider services,
|
||||
ILogger<BotBackgroundService> logger)
|
||||
ILogger<BotBackgroundService> logger,
|
||||
UserService userService)
|
||||
: BackgroundService
|
||||
{
|
||||
protected override Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
@ -29,11 +34,48 @@ public sealed class BotBackgroundService(
|
||||
using var scope = services.CreateScope();
|
||||
var commands = new Dictionary<string, ITelegramCommand>
|
||||
{
|
||||
["/start"] = scope.ServiceProvider.GetRequiredService<StartCommand>()
|
||||
//Commands
|
||||
["/start"] = scope.ServiceProvider.GetRequiredService<StartCommand>(),
|
||||
["/menu"] = scope.ServiceProvider.GetRequiredService<MenuCommand>(),
|
||||
["/info"] = scope.ServiceProvider.GetRequiredService<InfoCommand>(),
|
||||
|
||||
//Buttons
|
||||
[ButtonResource.EULAAgrement] = scope.ServiceProvider.GetRequiredService<EulaAgreementButtonCommand>(),
|
||||
};
|
||||
|
||||
if (update.Message?.Text is { } text && commands.TryGetValue(text, out var command))
|
||||
await command.ExecuteAsync(update, ct);
|
||||
if (update.Message is { Text: { } text, From: not null })
|
||||
{
|
||||
var user = await userService.GetUser(update, ct); //Проверка существования пользователя
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
await commands["/start"].ExecuteAsync(update, ct);
|
||||
return;
|
||||
}
|
||||
|
||||
if (commands.TryGetValue(text, out var command))
|
||||
{
|
||||
if (command is IAuthorizedTelegramCommand authorizedTelegramCommand)
|
||||
{
|
||||
var attribute = Attribute.GetCustomAttribute(
|
||||
command.GetType(),
|
||||
typeof(AcceptNotPreparedAttribute));
|
||||
if (!user.IsPrepared() && attribute is not AcceptNotPreparedAttribute)
|
||||
{
|
||||
await commands["/start"].ExecuteAsync(update, ct);
|
||||
//заставляем пользователя завершить регистрацию
|
||||
return;
|
||||
}
|
||||
|
||||
await authorizedTelegramCommand.ExecuteAsync(update, user, ct);
|
||||
}
|
||||
else await command.ExecuteAsync(update, ct);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
await bot.SendMessage(update.Message.From.Id, TextResource.CommandNotFound, cancellationToken: ct);
|
||||
}
|
||||
}
|
||||
|
||||
private Task HandleErrorAsync(ITelegramBotClient bot, Exception ex, CancellationToken ct)
|
||||
|
@ -1,18 +0,0 @@
|
||||
using User = JOBot.Proto.User;
|
||||
|
||||
namespace JOBot.TClient.Core.Services;
|
||||
|
||||
public class UserService(User.UserClient client)
|
||||
{
|
||||
public async Task<bool> RegisterAsync(long userId, string? username)
|
||||
{
|
||||
|
||||
var response = await client.RegisterAsync(new()
|
||||
{
|
||||
UserId = userId,
|
||||
Username = username
|
||||
});
|
||||
|
||||
return response.Success;
|
||||
}
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
using Grpc.Core;
|
||||
using Grpc.Net.Client;
|
||||
using JOBot.Proto;
|
||||
using JOBot.TClient.Commands;
|
||||
using JOBot.TClient.Core.Services;
|
||||
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;
|
||||
@ -19,15 +22,31 @@ public static class DependencyInjection
|
||||
services.AddScoped<ChannelBase, GrpcChannel>(_ => GrpcChannel.ForAddress(config.GetValue<string>("BackendHost")
|
||||
?? throw new MissingFieldException("Host is not defined")));
|
||||
|
||||
//Commands
|
||||
#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
|
||||
|
||||
//gRPC Clients
|
||||
services.AddScoped<User.UserClient>();
|
||||
#region States
|
||||
services.AddScoped<PrepareUserState>();
|
||||
#endregion
|
||||
|
||||
// Telegram Bot
|
||||
// Bot service
|
||||
services.AddHostedService<BotBackgroundService>();
|
||||
services.AddSingleton<ITelegramBotClient>(_ =>
|
||||
new TelegramBotClient(config.GetValue<string>("TelegramToken")
|
||||
?? throw new MissingFieldException("TelegramToken is not set")));
|
||||
|
@ -0,0 +1,4 @@
|
||||
namespace JOBot.TClient.Infrastructure.Attributes.Authorization;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
|
||||
public class AcceptNotPreparedAttribute : Attribute;
|
17
JOBot.TClient/Infrastructure/Exceptions/FallbackException.cs
Normal file
17
JOBot.TClient/Infrastructure/Exceptions/FallbackException.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace JOBot.TClient.Infrastructure.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// Exception for fallback
|
||||
/// WARNING: Don't create new exception without throwing it
|
||||
/// </summary>
|
||||
public class FallbackException : Exception
|
||||
{
|
||||
public FallbackException(string message, Message botMessage, ITelegramBotClient botClient) : base(message)
|
||||
{
|
||||
botClient.SendMessage(chatId: botMessage.Chat.Id,
|
||||
TextResource.FallbackMessage);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
using JOBot.Proto;
|
||||
|
||||
namespace JOBot.TClient.Infrastructure.Extensions;
|
||||
|
||||
public static class GRpcModelsExtensions
|
||||
{
|
||||
public static bool IsPrepared(this GetUserResponse user) => user is { Eula: true, IsLogged: true } &&
|
||||
!string.IsNullOrEmpty(user.CVUrl);
|
||||
}
|
@ -1,38 +1,60 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.30.2" />
|
||||
<PackageReference Include="Grpc.Net.Client" Version="2.71.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.71.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" 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.Hosting" Version="9.0.4" />
|
||||
<PackageReference Include="Telegram.Bot" Version="22.5.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.30.2"/>
|
||||
<PackageReference Include="Grpc.Net.Client" Version="2.71.0"/>
|
||||
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.71.0"/>
|
||||
<PackageReference Include="Grpc.Tools" Version="2.71.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" 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.Hosting" Version="9.0.4"/>
|
||||
<PackageReference Include="Telegram.Bot" Version="22.5.1"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Protobuf Include="..\Proto\*" GrpcServices="Client"></Protobuf>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Protobuf Include="..\Proto\*" GrpcServices="Client"></Protobuf>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.Example.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.Example.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Infrastucture\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="ButtonResource.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>ButtonResource.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="TextResource.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>TextResource.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="TextResource.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>TextResource.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="ButtonResource.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>ButtonResource.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,6 +1,4 @@
|
||||
using JOBot.TClient;
|
||||
using JOBot.TClient.Core.HostedServices;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
var host = Host.CreateDefaultBuilder(args)
|
||||
@ -9,8 +7,6 @@ var host = Host.CreateDefaultBuilder(args)
|
||||
// Настройка DI
|
||||
services.ConfigureServices(context.Configuration);
|
||||
|
||||
// Фоновый сервис для бота
|
||||
services.AddHostedService<BotBackgroundService>();
|
||||
})
|
||||
.Build();
|
||||
|
||||
|
17
JOBot.TClient/Services/MenuService.cs
Normal file
17
JOBot.TClient/Services/MenuService.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
using User = JOBot.Proto.User;
|
||||
|
||||
namespace JOBot.TClient.Services;
|
||||
|
||||
public class MenuService(ITelegramBotClient bot)
|
||||
{
|
||||
public Task RenderMenu(Update update, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
||||
|
||||
bot.SendMessage(update.Message.From.Id,"PrepareUser stage is done.", cancellationToken: ct);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
86
JOBot.TClient/Services/PrepareUserService.cs
Normal file
86
JOBot.TClient/Services/PrepareUserService.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using JOBot.Proto;
|
||||
using JOBot.TClient.Infrastructure.Exceptions;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
using User = JOBot.Proto.User;
|
||||
|
||||
namespace JOBot.TClient.Services;
|
||||
|
||||
public class PrepareUserService(ITelegramBotClient bot, User.UserClient userClient) : UserService(bot, userClient)
|
||||
{
|
||||
private readonly ITelegramBotClient _bot = bot;
|
||||
private readonly User.UserClient _userClient = userClient;
|
||||
|
||||
/// <summary>
|
||||
/// Get or register user on system
|
||||
/// </summary>
|
||||
/// <param name="update">Telegram Update object</param>
|
||||
/// <param name="ct">Cancellation Token</param>
|
||||
/// <returns>RPC User Response</returns>
|
||||
/// <exception cref="FallbackException">If something in server logic went wrong</exception>
|
||||
/// <exception cref="ArgumentNullException">If update.Message is null</exception>
|
||||
public async Task<GetUserResponse> RegisterUser(Update update, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
||||
|
||||
var result = await _userClient.RegisterAsync(new RegisterRequest
|
||||
{
|
||||
UserId = update.Message.From.Id,
|
||||
Username = update.Message.From.Username,
|
||||
});
|
||||
|
||||
if (!result.Success)
|
||||
{
|
||||
await _bot.SendMessage(chatId: update.Message.Chat.Id,
|
||||
TextResource.FallbackMessage,
|
||||
cancellationToken: ct);
|
||||
|
||||
throw new FallbackException(TextResource.FallbackMessage, update.Message, _bot);
|
||||
}
|
||||
|
||||
var user = await _userClient.GetUserAsync(new GetUserRequest()
|
||||
{
|
||||
UserId = update.Message.From.Id,
|
||||
});
|
||||
|
||||
if (user == null)
|
||||
throw new FallbackException(TextResource.FallbackMessage, update.Message, _bot);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Eula Agreement from user
|
||||
/// </summary>
|
||||
/// <param name="update">Telegram Update object</param>
|
||||
/// <param name="ct">Cancellation Token</param>
|
||||
/// <exception cref="ArgumentNullException">If update.Message is null</exception>
|
||||
public async Task AskForEulaAgreement(Update update, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
||||
|
||||
await _bot.SendMessage(
|
||||
update.Message.From.Id,
|
||||
TextResource.EULA,
|
||||
replyMarkup: new[] { ButtonResource.EULAAgrement }, cancellationToken: ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Accept EULA for user
|
||||
/// </summary>
|
||||
/// <param name="update">Telegram update object</param>
|
||||
/// <param name="ct">Cancellation Token</param>
|
||||
/// <exception cref="FallbackException">If something in server logic went wrong</exception>
|
||||
public async Task AcceptEula(Update update, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
||||
var result = await _userClient.AcceptEulaAsync(new()
|
||||
{
|
||||
EulaAccepted = true,
|
||||
UserId = update.Message.From.Id,
|
||||
});
|
||||
|
||||
if (!result.Success)
|
||||
throw new FallbackException(TextResource.FallbackMessage, update.Message, _bot);
|
||||
}
|
||||
}
|
41
JOBot.TClient/Services/UserService.cs
Normal file
41
JOBot.TClient/Services/UserService.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using Grpc.Core;
|
||||
using JOBot.Proto;
|
||||
using JOBot.TClient.Infrastructure.Exceptions;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
using User = JOBot.Proto.User;
|
||||
|
||||
namespace JOBot.TClient.Services;
|
||||
|
||||
public class UserService(ITelegramBotClient bot, User.UserClient userClient)
|
||||
{
|
||||
/// <summary>
|
||||
/// Get user
|
||||
/// </summary>
|
||||
/// <param name="update">Telegram Update object</param>
|
||||
/// <param name="ct">Cancellation Token</param>
|
||||
/// <returns>RPC User Response or null if user not exists</returns>
|
||||
/// <exception cref="FallbackException">If something in server logic went wrong</exception>
|
||||
/// <exception cref="ArgumentNullException">If update.Message is null</exception>
|
||||
public async Task<GetUserResponse?> GetUser(Update update, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
||||
|
||||
GetUserResponse? user;
|
||||
try
|
||||
{
|
||||
user = await userClient.GetUserAsync(new GetUserRequest() //Получаем пользователя
|
||||
{
|
||||
UserId = update.Message.From.Id,
|
||||
});
|
||||
}
|
||||
catch (RpcException e) //Пользователь не найден?
|
||||
{
|
||||
if (e.StatusCode != StatusCode.NotFound)
|
||||
throw new FallbackException(TextResource.FallbackMessage, update.Message, bot);
|
||||
|
||||
return null;
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
47
JOBot.TClient/Statements/PrepareUserState.cs
Normal file
47
JOBot.TClient/Statements/PrepareUserState.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using JOBot.TClient.Services;
|
||||
using Telegram.Bot.Types;
|
||||
using User = JOBot.Proto.User;
|
||||
|
||||
namespace JOBot.TClient.Statements;
|
||||
|
||||
public class PrepareUserState(PrepareUserService prepareUserService, MenuService menuService)
|
||||
{
|
||||
/// <summary>
|
||||
/// Try to prepare user if is not registered
|
||||
/// </summary>
|
||||
/// <param name="update">Update telegram object</param>
|
||||
/// <param name="ct">Cancellation token</param>
|
||||
public async Task TryToPrepareUser(Update update, CancellationToken ct = default)
|
||||
{
|
||||
var user = await prepareUserService.GetUser(update, ct) ?? await prepareUserService.RegisterUser(update, ct);
|
||||
|
||||
if (!user.Eula)
|
||||
{
|
||||
await prepareUserService.AskForEulaAgreement(update, ct);
|
||||
return; //interrupt while eula isn't accepted
|
||||
}
|
||||
|
||||
await OnUserEulaValidStage(update, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signal for accepted eula
|
||||
/// </summary>
|
||||
/// <param name="update"></param>
|
||||
/// <param name="ct"></param>
|
||||
public async Task AcceptEula(Update update, CancellationToken ct = default)
|
||||
{
|
||||
await prepareUserService.AcceptEula(update, ct: ct);
|
||||
await OnUserEulaValidStage(update, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Continue prepare stage
|
||||
/// </summary>
|
||||
/// <param name="update"></param>
|
||||
/// <param name="ct"></param>
|
||||
private async Task OnUserEulaValidStage(Update update, CancellationToken ct = default)
|
||||
{
|
||||
await menuService.RenderMenu(update, ct); //boilerplate
|
||||
}
|
||||
}
|
102
JOBot.TClient/TextResource.Designer.cs
generated
Normal file
102
JOBot.TClient/TextResource.Designer.cs
generated
Normal file
@ -0,0 +1,102 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace JOBot.TClient {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class TextResource {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal TextResource() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("JOBot.TClient.TextResource", typeof(TextResource).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Команда не найдена, попробуйте что-то другое.
|
||||
/// </summary>
|
||||
public static string CommandNotFound {
|
||||
get {
|
||||
return ResourceManager.GetString("CommandNotFound", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Продолжая, вы принимаете политику конфиденциальности и правила сервиса
|
||||
///
|
||||
///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".
|
||||
/// </summary>
|
||||
public static string EULA {
|
||||
get {
|
||||
return ResourceManager.GetString("EULA", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Something went REALLY wrong. Service can't continue process..
|
||||
/// </summary>
|
||||
public static string FallbackMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("FallbackMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Это бот для упрощения поиска работы на HH.ru.
|
||||
/// </summary>
|
||||
public static string Info {
|
||||
get {
|
||||
return ResourceManager.GetString("Info", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
37
JOBot.TClient/TextResource.resx
Normal file
37
JOBot.TClient/TextResource.resx
Normal file
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="EULA" xml:space="preserve">
|
||||
<value>Продолжая, вы принимаете политику конфиденциальности и правила сервиса
|
||||
|
||||
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"</value>
|
||||
</data>
|
||||
<data name="FallbackMessage" xml:space="preserve">
|
||||
<value>Something went REALLY wrong. Service can't continue process.</value>
|
||||
</data>
|
||||
<data name="CommandNotFound" xml:space="preserve">
|
||||
<value>Команда не найдена, попробуйте что-то другое</value>
|
||||
</data>
|
||||
<data name="Info" xml:space="preserve">
|
||||
<value>Это бот для упрощения поиска работы на HH.ru</value>
|
||||
</data>
|
||||
</root>
|
@ -4,6 +4,7 @@ option csharp_namespace = "JOBot.Proto";
|
||||
service User {
|
||||
rpc Register (RegisterRequest) returns (RegisterResponse);
|
||||
rpc GetUser (GetUserRequest) returns (GetUserResponse);
|
||||
rpc AcceptEula (AcceptEulaRequest) returns (AcceptEulaResponse);
|
||||
}
|
||||
|
||||
import "google/protobuf/wrappers.proto";
|
||||
@ -22,5 +23,18 @@ message GetUserRequest {
|
||||
}
|
||||
|
||||
message GetUserResponse {
|
||||
bool logged_to_hh = 1;
|
||||
int64 user_id = 1;
|
||||
google.protobuf.StringValue username = 2;
|
||||
bool eula = 3;
|
||||
bool is_logged = 4;
|
||||
google.protobuf.StringValue CVUrl = 5;
|
||||
}
|
||||
|
||||
message AcceptEulaRequest {
|
||||
int64 user_id = 1;
|
||||
bool eula_accepted = 2;
|
||||
}
|
||||
|
||||
message AcceptEulaResponse{
|
||||
bool success = 1;
|
||||
}
|
37
compose.dev.yml
Normal file
37
compose.dev.yml
Normal file
@ -0,0 +1,37 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15
|
||||
environment:
|
||||
POSTGRES_PASSWORD: LocalDbPass
|
||||
POSTGRES_DB: jobot
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- ./.docker/postgres_data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- jobot
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: JOBot.Backend/Dockerfile
|
||||
depends_on:
|
||||
- postgres
|
||||
ports:
|
||||
- "5001:5001"
|
||||
networks:
|
||||
- jobot
|
||||
|
||||
bot:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: JOBot.TClient/Dockerfile
|
||||
depends_on:
|
||||
- backend
|
||||
networks:
|
||||
- jobot
|
||||
|
||||
networks:
|
||||
jobot:
|
@ -6,8 +6,6 @@ services:
|
||||
environment:
|
||||
POSTGRES_PASSWORD: LocalDbPass
|
||||
POSTGRES_DB: jobot
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- ./.docker/postgres_data:/var/lib/postgresql/data
|
||||
networks:
|
||||
|
147
docs/UML/JOBotStateMachine.drawio
Normal file
147
docs/UML/JOBotStateMachine.drawio
Normal file
@ -0,0 +1,147 @@
|
||||
<mxfile host="Electron" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/27.0.9 Chrome/134.0.6998.205 Electron/35.4.0 Safari/537.36" version="27.0.9">
|
||||
<diagram name="/start" id="RBNtdg3dX3ngeTm1AG6C">
|
||||
<mxGraphModel dx="1248" dy="862" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-3" target="RWtiJw2BV4MPElkXuSfI-14">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="390" y="260" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-3" value="/start" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="330" y="140" width="120" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-13" value="PrepareUserValidator" style="rounded=0;whiteSpace=wrap;html=1;strokeColor=default;fillColor=none;dashed=1;dashPattern=8 8;labelPosition=left;verticalLabelPosition=top;align=right;verticalAlign=bottom;" vertex="1" parent="1">
|
||||
<mxGeometry x="120" y="250" width="640" height="1400" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-16" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-14" target="RWtiJw2BV4MPElkXuSfI-15">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-14" value="User = gRPC UserService -&gt; GetUser" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="330" y="280" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-18" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-15" target="RWtiJw2BV4MPElkXuSfI-17">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-23" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-15" target="RWtiJw2BV4MPElkXuSfI-21">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="300" y="400" />
|
||||
<mxPoint x="300" y="530" />
|
||||
<mxPoint x="390" y="530" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-15" value="User.Exists?" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="335" y="360" width="110" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-24" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-17" target="RWtiJw2BV4MPElkXuSfI-21">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="474" y="530" />
|
||||
<mxPoint x="390" y="530" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-17" value="gRPC UserService -&gt;<div>Register</div>" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="414" y="440" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-29" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-21" target="RWtiJw2BV4MPElkXuSfI-28">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-21" value="User.EULA?" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="331.25" y="550" width="117.5" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-25" value="True" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="290" y="370" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-27" value="False" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="430" y="370" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-33" value="&lt;&lt;inline button Accept&gt;&gt;" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;dashed=1;labelPosition=center;verticalLabelPosition=top;align=center;verticalAlign=bottom;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-28" target="RWtiJw2BV4MPElkXuSfI-31">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-28" value="SendEULA()" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="330" y="650" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-35" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-31" target="RWtiJw2BV4MPElkXuSfI-34">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-31" value="<div>&lt;&lt;signal&gt;&gt;</div><div>gRPC UserService -&gt; AcceptEULA</div>" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="330.25" y="760" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-47" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-34" target="RWtiJw2BV4MPElkXuSfI-37">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-55" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-34" target="RWtiJw2BV4MPElkXuSfI-46">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="263" y="920" />
|
||||
<mxPoint x="263" y="1160" />
|
||||
<mxPoint x="389" y="1160" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-34" value="User.Logged()?" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="282.75" y="880" width="215" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-44" value="&lt;&lt;HH.ru hook&gt;&gt;" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=middle;dashed=1;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-37" target="RWtiJw2BV4MPElkXuSfI-41">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-37" value="SendAskForAuth()" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="465" y="1000" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-53" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-41" target="RWtiJw2BV4MPElkXuSfI-46">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-41" value="&lt;&lt;signal&gt;&gt;<div>SendNotifyAuthSuccess()</div>" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="445" y="1080" width="160" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-56" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-46" target="RWtiJw2BV4MPElkXuSfI-54">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-67" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-46" target="RWtiJw2BV4MPElkXuSfI-66">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="262" y="1220" />
|
||||
<mxPoint x="262" y="1550" />
|
||||
<mxPoint x="526" y="1550" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-46" value="User.ResumeUrl.NullOrEmpty()?" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="281.75" y="1180" width="215" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-58" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-54" target="RWtiJw2BV4MPElkXuSfI-57">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-54" value="gRPC UserService -&gt; GetCVList" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="465" y="1290" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-61" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;dashed=1;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-57" target="RWtiJw2BV4MPElkXuSfI-60">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-62" value="&lt;&lt;inline button of CV pressed&gt;&gt;" style="edgeLabel;html=1;align=left;verticalAlign=middle;resizable=0;points=[];labelPosition=right;verticalLabelPosition=middle;" vertex="1" connectable="0" parent="RWtiJw2BV4MPElkXuSfI-61">
|
||||
<mxGeometry x="0.2305" y="2" relative="1" as="geometry">
|
||||
<mxPoint as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-57" value="SendAskForCVSelection()" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="448.75" y="1380" width="155" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-65" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="RWtiJw2BV4MPElkXuSfI-60">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="526.25" y="1560" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-60" value="<div>&lt;&lt;signal&gt;&gt;</div>ResumeSelected()" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="466.25" y="1480" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="RWtiJw2BV4MPElkXuSfI-66" value="/menu" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="466.25" y="1560" width="120" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
Loading…
x
Reference in New Issue
Block a user