139 lines
4.0 KiB
C#
139 lines
4.0 KiB
C#
using xIdentityHelper;
|
|
using System.Threading;
|
|
using xBotService.Models;
|
|
using xCommons.Providers;
|
|
using xCommons.Attributes;
|
|
using System.Threading.Tasks;
|
|
using xBotService.Interfaces;
|
|
using xBotService.Controllers;
|
|
using xCommons.Configurations;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Collections.Generic;
|
|
using xIdentityService.Interfaces;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using xBotService.Reciever;
|
|
|
|
namespace xServices.Controllers
|
|
{
|
|
[Authorize]
|
|
[RequireXPowered]
|
|
public class BotController : XBotProviderControllerBase
|
|
{
|
|
public BotController(
|
|
IXBotProvider botProvider,
|
|
ILogger<BotController> logger,
|
|
XAppConfiguration appConfiguration,
|
|
IXIdentityProvider identityProvider,
|
|
XValidationProvider validationProvider,
|
|
XBotBotUpdateRecieverBackgroundService botHandler
|
|
) : base(
|
|
logger: logger,
|
|
botHandler: botHandler,
|
|
botProvider: botProvider,
|
|
appConfiguration: appConfiguration,
|
|
identityProvider: identityProvider,
|
|
validationProvider: validationProvider
|
|
)
|
|
{ }
|
|
|
|
//
|
|
#region Override ...
|
|
[HttpGet("Me")]
|
|
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
|
public override async Task<ActionResult<XBotResUser>> GetMe(
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.GetMe(
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
[HttpGet("Updates")]
|
|
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
|
public override async Task<ActionResult<IList<XBotUpdateResponse>>> GetUpdates(
|
|
[FromQuery] XBotUpdatesRequest request,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.GetUpdates(
|
|
request: request,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
[HttpPost("Message")]
|
|
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
|
public override async Task<ActionResult<XBotMessage>> SendMessage(
|
|
[FromBody] XBotSendMessageRequest request,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.SendMessage(
|
|
request: request,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
|
[HttpPost("{botUserId}/ShowVerificationMenu")]
|
|
public override async Task<ActionResult<XBotMessage>> ShowVerificationMenu(
|
|
[FromRoute] long botUserId,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.ShowVerificationMenu(
|
|
botUserId: botUserId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
[HttpPost("{token}/VerifyUser")]
|
|
[Authorize(Policy = XPolicies.EnabledUser)]
|
|
public override async Task<ActionResult<XBotMessage>> VerifyUser(
|
|
[FromRoute] string token,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.VerifyUser(
|
|
token: token,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
[HttpPost("Refresh")]
|
|
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
|
public override async Task<ActionResult> Refresh(
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await base.Refresh(cancellationToken);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
}
|
|
} |