From 41fdb8abb034b80cb94915a4bfcae0fd4e57d64e Mon Sep 17 00:00:00 2001 From: silverpill Date: Sat, 14 Jan 2023 23:31:11 +0000 Subject: [PATCH] Rename activitypub::activity module to activitypub::types --- src/activitypub/builders/create_note.rs | 2 +- src/activitypub/fetcher/fetchers.rs | 8 +++++--- src/activitypub/fetcher/helpers.rs | 2 +- src/activitypub/handlers/create.rs | 4 ++-- src/activitypub/handlers/update.rs | 2 +- src/activitypub/mod.rs | 2 +- src/activitypub/{activity.rs => types.rs} | 2 ++ 7 files changed, 13 insertions(+), 9 deletions(-) rename src/activitypub/{activity.rs => types.rs} (93%) diff --git a/src/activitypub/builders/create_note.rs b/src/activitypub/builders/create_note.rs index ff009b5..864eeb4 100644 --- a/src/activitypub/builders/create_note.rs +++ b/src/activitypub/builders/create_note.rs @@ -3,7 +3,6 @@ use serde::Serialize; use tokio_postgres::GenericClient; use crate::activitypub::{ - activity::{Attachment, Tag}, actors::types::Actor, constants::{AP_MEDIA_TYPE, AP_CONTEXT, AP_PUBLIC}, deliverer::OutgoingActivity, @@ -13,6 +12,7 @@ use crate::activitypub::{ local_actor_subscribers, local_object_id, }, + types::{Attachment, Tag}, vocabulary::{CREATE, DOCUMENT, HASHTAG, LINK, MENTION, NOTE}, }; use crate::config::Instance; diff --git a/src/activitypub/fetcher/fetchers.rs b/src/activitypub/fetcher/fetchers.rs index f5237dd..4842b92 100644 --- a/src/activitypub/fetcher/fetchers.rs +++ b/src/activitypub/fetcher/fetchers.rs @@ -4,9 +4,11 @@ use std::time::Duration; use reqwest::{Client, Method, Proxy, RequestBuilder}; use serde_json::Value; -use crate::activitypub::activity::Object; -use crate::activitypub::actors::types::Actor; -use crate::activitypub::constants::AP_MEDIA_TYPE; +use crate::activitypub::{ + actors::types::Actor, + constants::AP_MEDIA_TYPE, + types::Object, +}; use crate::config::Instance; use crate::http_signatures::create::{ create_http_signature, diff --git a/src/activitypub/fetcher/helpers.rs b/src/activitypub/fetcher/helpers.rs index 3c622d3..b53abc3 100644 --- a/src/activitypub/fetcher/helpers.rs +++ b/src/activitypub/fetcher/helpers.rs @@ -4,11 +4,11 @@ use std::path::Path; use tokio_postgres::GenericClient; use crate::activitypub::{ - activity::Object, actors::helpers::{create_remote_profile, update_remote_profile}, handlers::create::handle_note, identifiers::parse_local_object_id, receiver::HandlerError, + types::Object, }; use crate::config::{Config, Instance}; use crate::database::DatabaseError; diff --git a/src/activitypub/handlers/create.rs b/src/activitypub/handlers/create.rs index bfd3ea0..8944d9e 100644 --- a/src/activitypub/handlers/create.rs +++ b/src/activitypub/handlers/create.rs @@ -7,7 +7,6 @@ use tokio_postgres::GenericClient; use uuid::Uuid; use crate::activitypub::{ - activity::{Attachment, Link, Object, Tag}, constants::{AP_MEDIA_TYPE, AP_PUBLIC, AS_MEDIA_TYPE}, fetcher::fetchers::fetch_file, fetcher::helpers::{ @@ -17,6 +16,7 @@ use crate::activitypub::{ }, identifiers::parse_local_actor_id, receiver::{parse_array, parse_property_value, HandlerError}, + types::{Attachment, Link, Object, Tag}, vocabulary::*, }; use crate::config::{Config, Instance}; @@ -417,8 +417,8 @@ pub async fn handle_create( mod tests { use serde_json::json; use crate::activitypub::{ - activity::Object, actors::types::Actor, + types::Object, vocabulary::NOTE, }; use super::*; diff --git a/src/activitypub/handlers/update.rs b/src/activitypub/handlers/update.rs index 62ca88e..e877ca2 100644 --- a/src/activitypub/handlers/update.rs +++ b/src/activitypub/handlers/update.rs @@ -4,12 +4,12 @@ use serde_json::Value; use tokio_postgres::GenericClient; use crate::activitypub::{ - activity::Object, actors::{ helpers::update_remote_profile, types::Actor, }, handlers::create::get_note_content, + types::Object, vocabulary::{NOTE, PERSON}, }; use crate::config::Config; diff --git a/src/activitypub/mod.rs b/src/activitypub/mod.rs index b9c0fe8..8f3baa9 100644 --- a/src/activitypub/mod.rs +++ b/src/activitypub/mod.rs @@ -1,4 +1,3 @@ -mod activity; pub mod actors; mod authentication; pub mod builders; @@ -10,6 +9,7 @@ mod handlers; pub mod identifiers; pub mod queues; mod receiver; +mod types; pub mod views; mod vocabulary; diff --git a/src/activitypub/activity.rs b/src/activitypub/types.rs similarity index 93% rename from src/activitypub/activity.rs rename to src/activitypub/types.rs index 956395a..2ce73c1 100644 --- a/src/activitypub/activity.rs +++ b/src/activitypub/types.rs @@ -41,6 +41,8 @@ pub struct Tag { #[cfg_attr(test, derive(Default))] #[serde(rename_all = "camelCase")] pub struct Object { + // https://www.w3.org/TR/activitypub/#obj-id + // "id" and "type" are required properties pub id: String, #[serde(rename = "type")]