V14 / fad4e1a110e5
MessageReceipt.cs
Lilith/Core/Messaging/MessageReceipt.cs
Changed in this versionCS
using System.Text.Json;
namespace Lilith.Core.Messaging;
public static class MessageReceipt
{
public static string ToReply(string receipt)
{
using var doc = JsonDocument.Parse(receipt);
var root = doc.RootElement;
string status = root.GetProperty("status").GetString()!;
string nickname = root.GetProperty("nickname").GetString()!;
var proposal = root.GetProperty("proposal");
string destination = nickname + " / " + proposal.GetProperty("room").GetString();
string text = proposal.GetProperty("text").GetString()!;
return status switch
{
"needs_approval" => "Prepared a local dummy message to " + destination + ":\n" + text + "\n" + root.GetProperty("instruction").GetString(),
"simulated_sent" => "Local dummy message to " + destination + ":\n" + text + "\nSimulated delivery only; no external channel was contacted.",
"rejected" => "Rejected the prepared message to " + destination + ". Nothing sent.",
_ => "Message outcome is unverified; no delivery is claimed."
};
}
}