Create activitypub::collections module
This commit is contained in:
parent
2703ab717a
commit
de15a57148
5 changed files with 33 additions and 23 deletions
|
@ -442,28 +442,6 @@ pub fn create_activity_update_person(
|
||||||
Ok(activity)
|
Ok(activity)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct OrderedCollection {
|
|
||||||
#[serde(rename = "@context")]
|
|
||||||
pub context: Value,
|
|
||||||
|
|
||||||
pub id: String,
|
|
||||||
|
|
||||||
#[serde(rename = "type")]
|
|
||||||
pub object_type: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl OrderedCollection {
|
|
||||||
pub fn new(collection_url: String) -> Self {
|
|
||||||
Self {
|
|
||||||
context: json!(AP_CONTEXT),
|
|
||||||
id: collection_url,
|
|
||||||
object_type: "OrderedCollection".to_string(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
27
src/activitypub/collections.rs
Normal file
27
src/activitypub/collections.rs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
use serde::Serialize;
|
||||||
|
use serde_json::{json, Value};
|
||||||
|
|
||||||
|
use super::constants::AP_CONTEXT;
|
||||||
|
use super::vocabulary::ORDERED_COLLECTION;
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct OrderedCollection {
|
||||||
|
#[serde(rename = "@context")]
|
||||||
|
pub context: Value,
|
||||||
|
|
||||||
|
pub id: String,
|
||||||
|
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
pub object_type: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OrderedCollection {
|
||||||
|
pub fn new(collection_id: String) -> Self {
|
||||||
|
Self {
|
||||||
|
context: json!(AP_CONTEXT),
|
||||||
|
id: collection_id,
|
||||||
|
object_type: ORDERED_COLLECTION.to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
pub mod activity;
|
pub mod activity;
|
||||||
pub mod actor;
|
pub mod actor;
|
||||||
|
mod collections;
|
||||||
pub mod constants;
|
pub mod constants;
|
||||||
pub mod deliverer;
|
pub mod deliverer;
|
||||||
pub mod fetcher;
|
pub mod fetcher;
|
||||||
|
|
|
@ -12,8 +12,9 @@ use crate::frontend::{get_post_page_url, get_profile_page_url};
|
||||||
use crate::http_signatures::verify::verify_http_signature;
|
use crate::http_signatures::verify::verify_http_signature;
|
||||||
use crate::models::posts::queries::get_thread;
|
use crate::models::posts::queries::get_thread;
|
||||||
use crate::models::users::queries::get_user_by_name;
|
use crate::models::users::queries::get_user_by_name;
|
||||||
use super::activity::{create_note, OrderedCollection};
|
use super::activity::create_note;
|
||||||
use super::actor::{get_local_actor, get_instance_actor};
|
use super::actor::{get_local_actor, get_instance_actor};
|
||||||
|
use super::collections::OrderedCollection;
|
||||||
use super::constants::ACTIVITY_CONTENT_TYPE;
|
use super::constants::ACTIVITY_CONTENT_TYPE;
|
||||||
use super::receiver::receive_activity;
|
use super::receiver::receive_activity;
|
||||||
use super::vocabulary::DELETE;
|
use super::vocabulary::DELETE;
|
||||||
|
|
|
@ -23,6 +23,9 @@ pub const MENTION: &str = "Mention";
|
||||||
pub const NOTE: &str = "Note";
|
pub const NOTE: &str = "Note";
|
||||||
pub const TOMBSTONE: &str = "Tombstone";
|
pub const TOMBSTONE: &str = "Tombstone";
|
||||||
|
|
||||||
|
// Collections
|
||||||
|
pub const ORDERED_COLLECTION: &str = "OrderedCollection";
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
pub const HASHTAG: &str = "Hashtag";
|
pub const HASHTAG: &str = "Hashtag";
|
||||||
pub const PROPERTY_VALUE: &str = "PropertyValue";
|
pub const PROPERTY_VALUE: &str = "PropertyValue";
|
||||||
|
|
Loading…
Reference in a new issue