♻️ Move the keys store out of the publisher meta

This commit is contained in:
2025-12-30 01:44:05 +08:00
parent 777c0c089a
commit 6a360fe697
6 changed files with 2774 additions and 13 deletions

View File

@@ -327,14 +327,25 @@ public class ActivityPubController(
private static string? GetPublisherKey(SnPublisher publisher, string keyName)
{
var metadata = publisher.Meta;
return metadata?.GetValueOrDefault(keyName)?.ToString();
return keyName switch
{
"private_key" => publisher.PrivateKeyPem,
"public_key" => publisher.PublicKeyPem,
_ => null
};
}
private static void SavePublisherKey(SnPublisher publisher, string keyName, string keyValue)
{
publisher.Meta ??= new Dictionary<string, object>();
publisher.Meta[keyName] = keyValue;
switch (keyName)
{
case "private_key":
publisher.PrivateKeyPem = keyValue;
break;
case "public_key":
publisher.PublicKeyPem = keyValue;
break;
}
}
}