Pause the school on warning notices until the owner dismisses them.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-20 22:33:38 +03:00
co-authored by Cursor
parent e22d9bae33
commit f36af269bb
27 changed files with 993 additions and 51 deletions
+39
View File
@@ -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);