Fix Verification User Senario ...

This commit is contained in:
2026-11-13 19:00:56 +03:30
parent 3e57ed6af9
commit 30c75ba03d
9 changed files with 289 additions and 374 deletions
+89 -188
View File
@@ -12,19 +12,22 @@ using System.Collections.Generic;
using xIdentityService.Interfaces;
using xIdentityService.Controllers;
using Microsoft.Extensions.Logging;
using xBotService.Reciever;
namespace xBotService.Controllers
{
public abstract class XBotProviderControllerBase : XBaseIdentityApiV1Controller
{
private readonly IXBotProvider botProvider;
private readonly XBotBotUpdateRecieverBackgroundService botHandler;
protected XBotProviderControllerBase(
IXBotProvider botProvider,
ILogger<XBotProviderControllerBase> logger,
XAppConfiguration appConfiguration,
IXIdentityProvider identityProvider,
XValidationProvider validationProvider
XValidationProvider validationProvider,
ILogger<XBotProviderControllerBase> logger,
XBotBotUpdateRecieverBackgroundService botHandler
) : base(
logger,
appConfiguration,
@@ -33,6 +36,7 @@ namespace xBotService.Controllers
)
{
this.botProvider = botProvider;
this.botHandler = botHandler;
}
//
@@ -130,200 +134,97 @@ namespace xBotService.Controllers
}
}
// [HttpPost("{chatId}/ShowVerificationMenu")]
// public virtual async Task<ActionResult<XBotMessageResponse>> ShowVerificationMenu(
// [FromRoute] long chatId,
// CancellationToken cancellationToken = default
// )
// {
// //
// try
// {
// //
// // Validation ...
// if (!ModelState.IsValid)
// {
// XException.InvalidArgs.Throw();
// }
// if (chatId <= 0)
// {
// XException.InvalidArgs.Throw();
// }
[HttpPost("{botUserId}/ShowVerificationMenu")]
public virtual async Task<ActionResult<XBotMessage>> ShowVerificationMenu(
[FromRoute] long botUserId,
CancellationToken cancellationToken = default
)
{
//
try
{
//
// Validation ...
if (botUserId <= 0)
{
XException.InvalidArgs.Throw();
}
// //
// var result = await botProvider.SendVerificationMenu(
// chatId: chatId,
// cancellationToken: cancellationToken
// );
//
var result = await botProvider.ShowVerificationMenu(
botUserId: botUserId,
cancellationToken: cancellationToken
);
// //
// return Ok(result.ToDynamicObject());
// }
// catch (Exception ex)
// {
// //
// var result = GetExceptionActionResult(ex);
// return result;
// }
// }
//
return Ok(result.ToDynamicObject());
}
catch (Exception ex)
{
//
var result = GetExceptionActionResult(ex);
return result;
}
}
// [HttpPost("{chatId}/SendVerificationCode")]
// public virtual async Task<ActionResult<XBotMessageResponse>> SendVerificationCode(
// [FromRoute] long chatId,
// [FromQuery] string code,
// [FromQuery] int ttlSeconds,
// CancellationToken cancellationToken = default
// )
// {
// //
// try
// {
// //
// // Validation ...
// if (!ModelState.IsValid)
// {
// XException.InvalidArgs.Throw();
// }
// if (chatId <= 0 || code.IsNullOrEmpty() || ttlSeconds < 60)
// {
// XException.InvalidArgs.Throw();
// }
[HttpPost("{token}/VerifyUser")]
public virtual async Task<ActionResult<XBotMessage>> VerifyUser(
[FromRoute] string token,
CancellationToken cancellationToken = default
)
{
//
try
{
//
// Validation ...
if (token.IsNullOrEmpty())
{
XException.InvalidArgs.Throw();
}
// //
// var result = await botProvider.SendVerificationCode(
// code: code,
// chatId: chatId,
// ttlSeconds: ttlSeconds,
// cancellationToken: cancellationToken
// );
//
var userInfo = await GetUserInfo();
// //
// return Ok(result.ToDynamicObject());
// }
// catch (Exception ex)
// {
// //
// var result = GetExceptionActionResult(ex);
// return result;
// }
// }
//
var result = await botProvider.VerifyUser(
token: token,
userInfo: userInfo,
cancellationToken: cancellationToken
);
// [HttpPost("{id}/AnswerCallback")]
// public virtual async Task<ActionResult<XBotMessageResponse>> AnswerCallbackQuery(
// [FromRoute] string callbackQueryId,
// [FromQuery] string text = null,
// [FromQuery] bool showAlert = false,
// CancellationToken cancellationToken = default
// )
// {
// //
// try
// {
// //
// // Validation ...
// if (!ModelState.IsValid ||
// callbackQueryId.IsNullOrEmpty())
// {
// XException.InvalidArgs.Throw();
// }
//
return Ok(result.ToDynamicObject());
}
catch (Exception ex)
{
//
var result = GetExceptionActionResult(ex);
return result;
}
}
// //
// var result = await botProvider.AnswerCallbackQuery(
// text: text,
// showAlert: showAlert,
// callbackQueryId: callbackQueryId,
// cancellationToken: cancellationToken
// );
[HttpPost("Refresh")]
public virtual async Task<ActionResult> Refresh(
CancellationToken cancellationToken = default
)
{
//
try
{
//
await botHandler.Refresh(cancellationToken);
// //
// return Ok(result.ToDynamicObject());
// }
// catch (Exception ex)
// {
// //
// var result = GetExceptionActionResult(ex);
// return result;
// }
// }
// [HttpPost("{chatId}/RemoveInlineKeyboard")]
// public virtual async Task<ActionResult<XBotMessageResponse>> RemoveInlineKeyboard(
// [FromRoute] long chatId,
// [FromQuery] long messageId,
// CancellationToken cancellationToken = default
// )
// {
// //
// try
// {
// //
// // Validation ...
// if (!ModelState.IsValid)
// {
// XException.InvalidArgs.Throw();
// }
// if (chatId <= 0 || messageId <= 0)
// {
// XException.InvalidArgs.Throw();
// }
// //
// var result = await botProvider.RemoveInlineKeyboard(
// chatId: chatId,
// messageId: messageId,
// cancellationToken: cancellationToken
// );
// //
// return Ok(result.ToDynamicObject());
// }
// catch (Exception ex)
// {
// //
// var result = GetExceptionActionResult(ex);
// return result;
// }
// }
// [HttpPost("Webhook")]
// public virtual async Task<ActionResult<bool>> SetWebhook(
// [FromQuery] string webhookUrl,
// [FromQuery] string secretToken = null,
// CancellationToken cancellationToken = default
// )
// {
// //
// try
// {
// //
// // Validation ...
// if (!ModelState.IsValid)
// {
// XException.InvalidArgs.Throw();
// }
// await ValidationProvider
// .GroupValidationBuilder()
// .AddNotEmpty(webhookUrl)
// .AddUrl(webhookUrl)
// .ValidateGroupAsync();
// //
// var result = await botProvider.SetWebhook(
// webhookUrl: webhookUrl,
// secretToken: secretToken,
// cancellationToken: cancellationToken
// );
// //
// return Ok(result);
// }
// catch (Exception ex)
// {
// //
// var result = GetExceptionActionResult(ex);
// return result;
// }
// }
//
return Ok();
}
catch (Exception ex)
{
//
var result = GetExceptionActionResult(ex);
return result;
}
}
#endregion
}
}