Skip to content

Commit

Permalink
Small fixup to accept activities
Browse files Browse the repository at this point in the history
Signed-off-by: Till Wegmueller <[email protected]>
  • Loading branch information
Toasterson committed Jul 25, 2023
1 parent 02f852e commit c53c13a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion crates/activitypub/src/activities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,56 @@ use serde_json::Value;
use std::collections::HashMap;

#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "type")]
#[serde(untagged)]
pub enum Activity {
Create(Create),
Follow(Follow),
Accept(Accept),
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum CreateType {
Create,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Create {
pub context: Context,
pub id: Url,
#[serde(rename = "type")]
pub kind: CreateType,
pub actor: Url,
pub published: chrono::NaiveDateTime,
pub to: Vec<Url>,
pub cc: Option<Vec<Url>>,
pub object: HashMap<String, Value>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum FollowType {
Follow,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Follow {
pub context: Context,
pub id: Url,
#[serde(rename = "type")]
pub kind: FollowType,
pub actor: Url,
#[serde(deserialize_with = "deserialize_skip_error", default)]
pub to: Option<[Url; 1]>,
pub object: Url,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum AcceptType {
Accept,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Accept {
pub context: Context,
pub id: Url,
#[serde(rename = "type")]
pub kind: AcceptType,
pub actor: Url,
#[serde(deserialize_with = "deserialize_skip_error", default)]
pub to: Option<[Url; 1]>,
Expand Down

0 comments on commit c53c13a

Please sign in to comment.