Add notification for ticket reopening to Telegram admins
CI / Backend (build + test) (push) Successful in 1m13s
CI / Frontend (lint + typecheck + build) (push) Successful in 31s

- Implemented NotifyAdminsTicketReopenedAsync method in TelegramNotifier to notify admins when a ticket is reopened, including a link to the ticket on the public site.
- Updated ITelegramNotifier interface to include the new notification method.
- Modified ReopenTicketCommandHandler to invoke the new notification method after a ticket is reopened.
- Enhanced unit tests for ReopenTicketCommandHandler to verify the notification functionality.
This commit is contained in:
Leonid Pershin
2026-07-14 07:22:21 +03:00
parent a833d9aa5b
commit 9d5424bb9c
4 changed files with 50 additions and 4 deletions
@@ -1,3 +1,5 @@
using PnvPanel.Domain.Support;
namespace PnvPanel.Application.Common.Interfaces;
/// <summary>
@@ -25,4 +27,8 @@ public interface ITelegramNotifier
/// <summary>Рассылка о публикации новости всем активированным пользователям с привязанным Telegram
/// (кнопка-ссылка на сайт, где новость показана целиком).</summary>
Task NotifyUsersNewsPublishedAsync(string title, CancellationToken cancellationToken);
/// <summary>Пользователь переоткрыл решённый тикет — только кнопка-ссылка на сайт, без
/// инлайн-действий (аналогично баг-репортам).</summary>
Task NotifyAdminsTicketReopenedAsync(Guid ticketId, string userName, TicketType type, CancellationToken cancellationToken);
}
@@ -7,7 +7,7 @@ using PnvPanel.Domain.Support;
namespace PnvPanel.Application.Support.Reopen;
public sealed class ReopenTicketCommandHandler(IAppDbContext dbContext, ICurrentUser currentUser)
public sealed class ReopenTicketCommandHandler(IAppDbContext dbContext, ITelegramNotifier telegramNotifier, ICurrentUser currentUser)
: ICommandHandler<ReopenTicketCommand, Result>
{
public async Task<Result> Handle(ReopenTicketCommand command, CancellationToken cancellationToken)
@@ -24,6 +24,10 @@ public sealed class ReopenTicketCommandHandler(IAppDbContext dbContext, ICurrent
return Result.Failure(SupportErrors.NotResolved);
ticket.Reopen();
var userName = currentUser.UserName ?? userId.ToString();
await telegramNotifier.NotifyAdminsTicketReopenedAsync(ticket.Id, userName, ticket.Type, cancellationToken);
return Result.Success();
}
}