Add speech-topic policy from tomorrow and a morning family talk.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-20 13:53:12 +03:00
co-authored by Cursor
parent 5e147a8e47
commit 92c2143329
31 changed files with 909 additions and 35 deletions
@@ -0,0 +1,47 @@
using HSchool.Content;
namespace HSchool.Server.Api;
internal sealed record SpeechRulesResponse(
string Students,
string Staff,
string? PendingStudents,
string? PendingStaff)
{
public static SpeechRulesResponse From(SchoolSpeechRules rules) =>
new(rules.Students, rules.Staff, rules.PendingStudents, rules.PendingStaff);
}
internal sealed record SetSpeechRulesRequest(string? Students, string? Staff);
internal enum SpeechRulesError
{
None,
UnknownSchool,
UnknownPolicy,
}
internal sealed record SpeechRulesOutcome(SpeechRulesError Error, SpeechRulesResponse? Rules)
{
public static SpeechRulesOutcome Ok(SchoolSpeechRules rules) =>
new(SpeechRulesError.None, SpeechRulesResponse.From(rules));
public static SpeechRulesOutcome Fail(SpeechRulesError error) => new(error, null);
}
internal static class SpeechRulesValidation
{
public static bool TryParse(string value, out string policy, out SpeechRulesError error)
{
if (!SpeechPolicies.IsKnown(value))
{
policy = "";
error = SpeechRulesError.UnknownPolicy;
return false;
}
policy = value;
error = SpeechRulesError.None;
return true;
}
}