Add notification for ticket reopening to Telegram admins
- 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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user