Add Telegram bot integration and enhance user management features
- Introduced Telegram.Bot package for bot functionality. - Updated user management to include Telegram linking and blocking features. - Enhanced activation request handling with notifications via Telegram. - Added new database entities for Telegram link tokens and login requests. - Implemented traffic synchronization for client stats in the XuiPanelGateway. - Updated application structure to support new test projects and improved dependency injection for Telegram services.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using PnvPanel.Application.Auth;
|
||||
using PnvPanel.Application.Common.Interfaces;
|
||||
using PnvPanel.Application.Common.Messaging;
|
||||
using PnvPanel.Application.Common.Models;
|
||||
using PnvPanel.Domain.Telegram;
|
||||
|
||||
namespace PnvPanel.Application.Telegram;
|
||||
|
||||
public sealed class CreateLinkTokenCommandHandler(IAppDbContext dbContext, ICurrentUser currentUser)
|
||||
: ICommandHandler<CreateLinkTokenCommand, Result<LinkTokenDto>>
|
||||
{
|
||||
private static readonly TimeSpan Ttl = TimeSpan.FromMinutes(5);
|
||||
|
||||
public Task<Result<LinkTokenDto>> Handle(CreateLinkTokenCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
if (currentUser.UserId is not { } userId)
|
||||
return Task.FromResult(Result.Failure<LinkTokenDto>(AuthErrors.Unauthorized));
|
||||
|
||||
var token = TelegramLinkToken.Create(userId, Ttl);
|
||||
dbContext.TelegramLinkTokens.Add(token);
|
||||
|
||||
return Task.FromResult(Result.Success(new LinkTokenDto(token.Token, token.ExpiresAt)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user