Enhance Telegram bot integration and notification system
- Updated PnvBotUpdateHandler to improve message editing for login and activation requests, providing clearer feedback and removing lingering buttons. - Modified TelegramNotifier to include an optional button linking to the public site in user notifications. - Enhanced CloseTicketCommandHandler and ResolveTicketCommandHandler to notify users via Telegram when their support tickets are closed or resolved, improving user engagement. - Updated ITelegramNotifier interface documentation to reflect the new functionality of including a site link in user notifications.
This commit is contained in:
@@ -9,7 +9,8 @@ using PnvPanel.Domain.Support;
|
||||
|
||||
namespace PnvPanel.Application.Admin.Support;
|
||||
|
||||
public sealed class CloseTicketCommandHandler(IAppDbContext dbContext, IRealtimeNotifier notifier, ICurrentUser currentUser)
|
||||
public sealed class CloseTicketCommandHandler(
|
||||
IAppDbContext dbContext, IRealtimeNotifier notifier, ITelegramNotifier telegramNotifier, ICurrentUser currentUser)
|
||||
: ICommandHandler<CloseTicketCommand, Result>
|
||||
{
|
||||
public async Task<Result> Handle(CloseTicketCommand command, CancellationToken cancellationToken)
|
||||
@@ -30,6 +31,7 @@ public sealed class CloseTicketCommandHandler(IAppDbContext dbContext, IRealtime
|
||||
adminId, "TicketClosed", "SupportTicket", ticket.Id.ToString(), metadata: null, AuditSource.Web));
|
||||
|
||||
await notifier.NotifyTicketUpdatedAsync(ticket.Id, ticket.UserId, cancellationToken);
|
||||
await telegramNotifier.NotifyUserAsync(ticket.UserId, "🔒 Ваше обращение закрыто.", cancellationToken);
|
||||
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ using PnvPanel.Domain.Support;
|
||||
|
||||
namespace PnvPanel.Application.Admin.Support;
|
||||
|
||||
public sealed class ResolveTicketCommandHandler(IAppDbContext dbContext, IRealtimeNotifier notifier, ICurrentUser currentUser)
|
||||
public sealed class ResolveTicketCommandHandler(
|
||||
IAppDbContext dbContext, IRealtimeNotifier notifier, ITelegramNotifier telegramNotifier, ICurrentUser currentUser)
|
||||
: ICommandHandler<ResolveTicketCommand, Result>
|
||||
{
|
||||
public async Task<Result> Handle(ResolveTicketCommand command, CancellationToken cancellationToken)
|
||||
@@ -30,6 +31,7 @@ public sealed class ResolveTicketCommandHandler(IAppDbContext dbContext, IRealti
|
||||
adminId, "TicketResolved", "SupportTicket", ticket.Id.ToString(), metadata: null, AuditSource.Web));
|
||||
|
||||
await notifier.NotifyTicketUpdatedAsync(ticket.Id, ticket.UserId, cancellationToken);
|
||||
await telegramNotifier.NotifyUserAsync(ticket.UserId, "✅ Ваше обращение решено.", cancellationToken);
|
||||
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ public interface ITelegramNotifier
|
||||
Task NotifyAdminsActivationRequestedAsync(
|
||||
Guid requestId, string userName, string? comment, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Личное сообщение пользователю, если у него привязан Telegram (иначе no-op).</summary>
|
||||
/// <summary>Личное сообщение пользователю, если у него привязан Telegram (иначе no-op).
|
||||
/// Если задан PublicSiteUrl — добавляет кнопку-ссылку на сайт.</summary>
|
||||
Task NotifyUserAsync(Guid userId, string message, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Баг-репорт/предложение — только кнопка-ссылка на сайт (переписка и картинки — там),
|
||||
|
||||
Reference in New Issue
Block a user