Pause the school on warning notices until the owner dismisses them.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -38,6 +38,43 @@ internal static class DevEndpoints
|
||||
return Results.Ok(MapDump(published, live));
|
||||
})
|
||||
.WithName("DumpSchool");
|
||||
|
||||
builder.MapPost("/api/dev/schools/{id:int}/notices", async (
|
||||
int id,
|
||||
PostDevNoticeRequest? request,
|
||||
GameLoopService loop,
|
||||
GameCommandQueue commands,
|
||||
CancellationToken cancellationToken) =>
|
||||
{
|
||||
if (loop.FindSchool(id) is null)
|
||||
{
|
||||
return Problem(StatusCodes.Status404NotFound, "unknown-school", "That school does not exist.");
|
||||
}
|
||||
|
||||
var defName = request?.DefName?.Trim() ?? "";
|
||||
if (defName.Length == 0)
|
||||
{
|
||||
return Problem(StatusCodes.Status400BadRequest, "invalid-query", "defName is required.");
|
||||
}
|
||||
|
||||
var command = new GameCommand.PostSchoolNotice(
|
||||
id,
|
||||
defName,
|
||||
request?.PersonId ?? 0,
|
||||
NewCompletion<PostedNotice?>());
|
||||
commands.Enqueue(command);
|
||||
var posted = await command.Result.Task.WaitAsync(CommandTimeout, cancellationToken);
|
||||
if (posted is null)
|
||||
{
|
||||
return Problem(
|
||||
StatusCodes.Status409Conflict,
|
||||
"notice-rejected",
|
||||
"Unknown event def or the sticky notice ceiling is full.");
|
||||
}
|
||||
|
||||
return Results.Ok(new { id = posted.Id, defName = posted.DefName, pause = posted.Pause });
|
||||
})
|
||||
.WithName("PostDevNotice");
|
||||
}
|
||||
|
||||
private static SchoolDumpResponse MapDump(PublishedSchoolPeople published, SchoolLiveDump live)
|
||||
@@ -115,3 +152,5 @@ internal sealed record SchoolDumpLessonResponse(
|
||||
string RoomId,
|
||||
int Day,
|
||||
int Period);
|
||||
|
||||
internal sealed record PostDevNoticeRequest(string? DefName, uint PersonId);
|
||||
|
||||
Reference in New Issue
Block a user