diff options
Diffstat (limited to 'kittybox-rs/src')
-rw-r--r-- | kittybox-rs/src/micropub/mod.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/kittybox-rs/src/micropub/mod.rs b/kittybox-rs/src/micropub/mod.rs index da9c6a5..a55ea15 100644 --- a/kittybox-rs/src/micropub/mod.rs +++ b/kittybox-rs/src/micropub/mod.rs @@ -1,3 +1,5 @@ +use std::collections::HashMap; + use crate::database::{MicropubChannel, Storage, StorageError}; use crate::indieauth::backend::AuthBackend; use crate::indieauth::User; @@ -317,6 +319,12 @@ enum ActionType { Update, } +#[derive(Serialize, Deserialize, Debug)] +#[serde(untagged)] +pub enum MicropubPropertyDeletion { + Properties(Vec<String>), + Values(HashMap<String, serde_json::Value>) +} #[derive(Serialize, Deserialize)] struct MicropubFormAction { action: ActionType, @@ -324,19 +332,20 @@ struct MicropubFormAction { } #[derive(Serialize, Deserialize, Debug)] -struct MicropubAction { +pub struct MicropubAction { action: ActionType, url: String, #[serde(skip_serializing_if = "Option::is_none")] - replace: Option<serde_json::Value>, + replace: Option<HashMap<String, serde_json::Value>>, #[serde(skip_serializing_if = "Option::is_none")] - add: Option<serde_json::Value>, + add: Option<HashMap<String, serde_json::Value>>, #[serde(skip_serializing_if = "Option::is_none")] - delete: Option<serde_json::Value>, + delete: Option<MicropubPropertyDeletion>, } impl From<MicropubFormAction> for MicropubAction { fn from(a: MicropubFormAction) -> Self { + debug_assert!(matches!(a.action, ActionType::Delete)); Self { action: a.action, url: a.url, |