| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Workflows.Api.Endpoints.BookmarkQueueDeadLetters; |
| | | 3 | | using Elsa.Workflows.Runtime; |
| | | 4 | | using JetBrains.Annotations; |
| | | 5 | | using Microsoft.AspNetCore.Http; |
| | | 6 | | |
| | | 7 | | namespace Elsa.Workflows.Api.Endpoints.BookmarkQueueDeadLetters.Replay; |
| | | 8 | | |
| | | 9 | | [UsedImplicitly] |
| | 3 | 10 | | internal class Endpoint(IBookmarkQueueDeadLetterManager manager) : ElsaEndpointWithoutRequest<ReplayResponse> |
| | | 11 | | { |
| | | 12 | | public override void Configure() |
| | | 13 | | { |
| | 3 | 14 | | Post("/bookmark-queue/dead-letters/{id}/replay"); |
| | 3 | 15 | | ConfigurePermissions(PermissionNames.ReplayBookmarkQueueDeadLetters); |
| | 3 | 16 | | } |
| | | 17 | | |
| | | 18 | | public override async Task HandleAsync(CancellationToken cancellationToken) |
| | | 19 | | { |
| | 0 | 20 | | var id = Route<string>("id")!; |
| | 0 | 21 | | var result = await manager.ReplayAsync(id, cancellationToken); |
| | | 22 | | |
| | 0 | 23 | | if (result.Reason == ReplayBookmarkQueueDeadLetterResult.ReasonNotFound) |
| | | 24 | | { |
| | 0 | 25 | | await Send.NotFoundAsync(cancellationToken); |
| | 0 | 26 | | return; |
| | | 27 | | } |
| | | 28 | | |
| | 0 | 29 | | if (!result.Succeeded) |
| | | 30 | | { |
| | 0 | 31 | | await Send.ResponseAsync(new ReplayResponse(false, result.QueueItemId, result.Reason), StatusCodes.Status409 |
| | 0 | 32 | | return; |
| | | 33 | | } |
| | | 34 | | |
| | 0 | 35 | | await Send.OkAsync(new ReplayResponse(true, result.QueueItemId, null), cancellationToken); |
| | 0 | 36 | | } |
| | | 37 | | } |