2022-12-19 21:20:13 +01:00
|
|
|
use axum::{response::IntoResponse, Json};
|
2022-12-20 00:15:00 +01:00
|
|
|
use serde::{Deserialize, Serialize};
|
2022-12-11 01:07:39 +01:00
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
pub struct Actor {
|
|
|
|
#[serde(rename = "@context")]
|
|
|
|
pub jsonld_context: serde_json::Value,
|
|
|
|
#[serde(rename = "type")]
|
|
|
|
pub actor_type: String,
|
|
|
|
pub id: String,
|
|
|
|
pub inbox: String,
|
|
|
|
#[serde(rename = "publicKey")]
|
|
|
|
pub public_key: ActorPublicKey,
|
2022-12-12 21:31:42 +01:00
|
|
|
#[serde(rename = "preferredUsername")]
|
2022-12-19 21:20:13 +01:00
|
|
|
pub preferred_username: Option<String>,
|
2022-12-11 01:07:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
pub struct ActorPublicKey {
|
|
|
|
pub id: String,
|
|
|
|
pub owner: Option<String>,
|
|
|
|
#[serde(rename = "publicKeyPem")]
|
|
|
|
pub pem: String,
|
|
|
|
}
|
|
|
|
|
2022-12-20 00:15:00 +01:00
|
|
|
/// `ActivityPub` "activity"
|
2022-12-11 01:07:39 +01:00
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
pub struct Action<O> {
|
2022-12-13 04:12:35 +01:00
|
|
|
#[serde(rename = "@context")]
|
|
|
|
pub jsonld_context: serde_json::Value,
|
2022-12-11 01:07:39 +01:00
|
|
|
#[serde(rename = "type")]
|
|
|
|
pub action_type: String,
|
2022-12-13 04:12:35 +01:00
|
|
|
pub id: String,
|
2022-12-11 01:07:39 +01:00
|
|
|
pub actor: String,
|
|
|
|
pub to: Option<String>,
|
|
|
|
pub object: Option<O>,
|
|
|
|
}
|
2022-12-19 21:20:13 +01:00
|
|
|
|
|
|
|
impl IntoResponse for Actor {
|
|
|
|
fn into_response(self) -> axum::response::Response {
|
|
|
|
([("content-type", "application/activity+json")],
|
|
|
|
Json(self)).into_response()
|
|
|
|
}
|
|
|
|
}
|