fedimovies/src/activitypub/activity.rs

63 lines
1.5 KiB
Rust
Raw Normal View History

2021-04-09 00:22:17 +00:00
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use super::vocabulary::HASHTAG;
2021-04-09 00:22:17 +00:00
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Attachment {
#[serde(rename = "type")]
pub attachment_type: String,
pub name: Option<String>,
pub media_type: Option<String>,
pub url: Option<String>,
2021-04-09 00:22:17 +00:00
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Link {
pub href: String,
}
2022-02-15 23:14:39 +00:00
fn default_tag_type() -> String { HASHTAG.to_string() }
2021-11-11 21:51:47 +00:00
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Tag {
pub name: Option<String>,
2021-11-11 21:51:47 +00:00
2022-02-15 23:14:39 +00:00
#[serde(rename = "type", default = "default_tag_type")]
2021-11-11 21:51:47 +00:00
pub tag_type: String,
pub href: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub media_type: Option<String>,
2021-11-11 21:51:47 +00:00
}
#[derive(Deserialize)]
#[cfg_attr(test, derive(Default))]
2021-04-09 00:22:17 +00:00
#[serde(rename_all = "camelCase")]
pub struct Object {
pub id: String,
#[serde(rename = "type")]
pub object_type: String,
pub name: Option<String>,
pub attachment: Option<Value>,
pub cc: Option<Value>,
pub media_type: Option<String>,
2021-04-09 00:22:17 +00:00
pub published: Option<DateTime<Utc>>,
pub attributed_to: Option<Value>,
2021-04-09 00:22:17 +00:00
pub in_reply_to: Option<String>,
pub content: Option<String>,
pub quote_url: Option<String>,
pub tag: Option<Value>,
2021-04-09 00:22:17 +00:00
pub to: Option<Value>,
2022-05-11 12:50:36 +00:00
pub updated: Option<DateTime<Utc>>,
pub url: Option<Value>,
2021-04-09 00:22:17 +00:00
}