feat(developers): fix approval webhook flow and add ticket parsing service
All checks were successful
Build and Deploy / deploy (push) Successful in 16s
All checks were successful
Build and Deploy / deploy (push) Successful in 16s
Change approve endpoint from int to string ticketId to match SilverDESK GUIDs. Remove body parameter requirement so the endpoint works as a webhook target. Add DeveloperTicketParsingService to fetch and parse applicant details from ticket descriptions. Remove redundant ticket status update from ProvisioningService since SilverDESK action engine now handles SetStatus/AddNote/AddReply steps. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,10 +17,10 @@ public static class DeveloperEndpoints
|
||||
: Results.Problem(message, statusCode: 502);
|
||||
});
|
||||
|
||||
group.MapPost("/approve/{ticketId:int}", async (
|
||||
int ticketId,
|
||||
ApproveRequest request,
|
||||
ProvisioningService service,
|
||||
group.MapPost("/approve/{ticketId}", async (
|
||||
string ticketId,
|
||||
DeveloperTicketParsingService ticketService,
|
||||
ProvisioningService provisioningService,
|
||||
HttpContext context,
|
||||
IConfiguration config) =>
|
||||
{
|
||||
@@ -30,8 +30,18 @@ public static class DeveloperEndpoints
|
||||
if (string.IsNullOrEmpty(expectedKey) || apiKey != expectedKey)
|
||||
return Results.Unauthorized();
|
||||
|
||||
var (success, message) = await service.ApproveApplicationAsync(
|
||||
ticketId, request.Username, request.Email, request.FullName);
|
||||
var ticket = await ticketService.FetchTicketAsync(ticketId);
|
||||
if (ticket is null)
|
||||
return Results.Problem("Failed to fetch ticket from SilverDESK", statusCode: 502);
|
||||
|
||||
var description = ticket.Value.GetProperty("description").GetString() ?? "";
|
||||
var (fullName, email, desiredUsername) = ticketService.ParseApplicationFromDescription(description);
|
||||
|
||||
if (string.IsNullOrEmpty(fullName) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(desiredUsername))
|
||||
return Results.Problem("Could not parse applicant details from ticket description", statusCode: 422);
|
||||
|
||||
var (success, message) = await provisioningService.ApproveApplicationAsync(
|
||||
ticketId, desiredUsername, email, fullName);
|
||||
|
||||
return success
|
||||
? Results.Ok(new { message })
|
||||
@@ -39,5 +49,3 @@ public static class DeveloperEndpoints
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public record ApproveRequest(string Username, string Email, string FullName);
|
||||
|
||||
Reference in New Issue
Block a user