Add speech-topic policy from tomorrow and a morning family talk.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user