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 NSubstitute;
using PnvPanel.Application.Common.Interfaces;
using PnvPanel.Application.Support;
using PnvPanel.Application.Support.Reopen;
using PnvPanel.Application.Tests.TestSupport;
@@ -8,6 +10,8 @@ namespace PnvPanel.Application.Tests.Support;
public class ReopenTicketCommandHandlerTests
{
private readonly ITelegramNotifier _telegramNotifier = Substitute.For<ITelegramNotifier>();
[Fact]
public async Task Handle_WhenResolved_SetsOpen()
{
@@ -19,12 +23,14 @@ public class ReopenTicketCommandHandlerTests
await dbContext.SaveChangesAsync(CancellationToken.None);
var currentUser = FakeCurrentUser.Authenticated(userId);
var handler = new ReopenTicketCommandHandler(dbContext, currentUser);
var handler = new ReopenTicketCommandHandler(dbContext, _telegramNotifier, currentUser);
var result = await handler.Handle(new ReopenTicketCommand(ticket.Id), CancellationToken.None);
Assert.True(result.IsSuccess);
Assert.Equal(TicketStatus.Open, ticket.Status);
await _telegramNotifier.Received(1).NotifyAdminsTicketReopenedAsync(
ticket.Id, Arg.Any<string>(), TicketType.BugReport, Arg.Any<CancellationToken>());
}
[Fact]
@@ -37,7 +43,7 @@ public class ReopenTicketCommandHandlerTests
await dbContext.SaveChangesAsync(CancellationToken.None);
var currentUser = FakeCurrentUser.Authenticated(userId);
var handler = new ReopenTicketCommandHandler(dbContext, currentUser);
var handler = new ReopenTicketCommandHandler(dbContext, _telegramNotifier, currentUser);
var result = await handler.Handle(new ReopenTicketCommand(ticket.Id), CancellationToken.None);
@@ -55,7 +61,7 @@ public class ReopenTicketCommandHandlerTests
await dbContext.SaveChangesAsync(CancellationToken.None);
var currentUser = FakeCurrentUser.Authenticated(Guid.NewGuid());
var handler = new ReopenTicketCommandHandler(dbContext, currentUser);
var handler = new ReopenTicketCommandHandler(dbContext, _telegramNotifier, currentUser);
var result = await handler.Handle(new ReopenTicketCommand(ticket.Id), CancellationToken.None);