diff --git a/packages/backend-rs/src/federation/activitypub/object/accept.rs b/packages/backend-rs/src/federation/activitypub/object/accept.rs index e9147f4d09..fd6118d56c 100644 --- a/packages/backend-rs/src/federation/activitypub/object/accept.rs +++ b/packages/backend-rs/src/federation/activitypub/object/accept.rs @@ -5,19 +5,19 @@ use uuid::Uuid; #[macros::export(object)] pub struct ApAccept { pub id: String, - pub r#type: ApObject, + pub r#type: Activity, pub actor: String, pub object: follow::ApFollow, } -impl ActivityPubObject for ApAccept {} +impl ApObject for ApAccept {} impl ApAccept { - #[allow(dead_code)] // TODO: remove this line + #[allow(dead_code)] // TODO: remove this line by actually using it fn new(user_id: String, follow_object: follow::ApFollow) -> Self { Self { id: format!("{}/{}", CONFIG.url, Uuid::new_v4()), - r#type: ApObject::Accept, + r#type: Activity::Accept, actor: user::local_uri(user_id), object: follow_object, } diff --git a/packages/backend-rs/src/federation/activitypub/object/add.rs b/packages/backend-rs/src/federation/activitypub/object/add.rs index 4d34ae3b1f..183e38c75f 100644 --- a/packages/backend-rs/src/federation/activitypub/object/add.rs +++ b/packages/backend-rs/src/federation/activitypub/object/add.rs @@ -5,22 +5,22 @@ use crate::misc::{note, user}; #[macros::export(object)] pub struct ApAdd { - pub r#type: ApObject, + pub r#type: Activity, pub actor: String, pub target: String, pub object: String, } -impl ActivityPubObject for ApAdd {} +impl ApObject for ApAdd {} impl ApAdd { - #[allow(dead_code)] // TODO: remove this line + #[allow(dead_code)] // TODO: remove this line by actually using it fn new(user_id: String, note_id: String) -> Self { let actor_uri = user::local_uri(user_id); let collection_uri = format!("{}/collections/featured", actor_uri); Self { - r#type: ApObject::Add, + r#type: Activity::Add, actor: actor_uri, target: collection_uri, object: note::local_uri(note_id), diff --git a/packages/backend-rs/src/federation/activitypub/object/emoji.rs b/packages/backend-rs/src/federation/activitypub/object/emoji.rs index 14e47168cb..afc8b00873 100644 --- a/packages/backend-rs/src/federation/activitypub/object/emoji.rs +++ b/packages/backend-rs/src/federation/activitypub/object/emoji.rs @@ -5,7 +5,7 @@ use chrono::Utc; #[macros::export(object)] pub struct ApEmoji { pub id: String, - pub r#type: ApObject, + pub r#type: Activity, pub name: String, pub updated: String, pub icon: Icon, @@ -13,25 +13,25 @@ pub struct ApEmoji { #[macros::export(object)] pub struct Icon { - pub r#type: ApObject, + pub r#type: Activity, pub media_type: String, pub url: String, } -impl ActivityPubObject for ApEmoji {} +impl ApObject for ApEmoji {} impl ApEmoji { pub fn new(emoji: emoji::Model) -> Self { Self { id: misc::emoji::local_uri(&emoji.name), - r#type: ApObject::Emoji, + r#type: Activity::Emoji, name: format!(":{}:", emoji.name), updated: emoji .updated_at .unwrap_or_else(|| Utc::now().into()) .to_rfc3339(), icon: Icon { - r#type: ApObject::Image, + r#type: Activity::Image, media_type: emoji.r#type.unwrap_or_else(|| "image/png".to_owned()), url: emoji.public_url, }, diff --git a/packages/backend-rs/src/federation/activitypub/object/flag.rs b/packages/backend-rs/src/federation/activitypub/object/flag.rs index 0ade189d30..3b37b6049e 100644 --- a/packages/backend-rs/src/federation/activitypub/object/flag.rs +++ b/packages/backend-rs/src/federation/activitypub/object/flag.rs @@ -3,23 +3,23 @@ use crate::{federation::internal_actor, misc::user}; #[macros::export(object)] pub struct ApFlag { - pub r#type: ApObject, + pub r#type: Activity, pub actor: String, pub content: String, // TODO: object can be an array of uri's pub object: String, } -impl ActivityPubObject for ApFlag {} +impl ApObject for ApFlag {} impl ApFlag { - #[allow(dead_code)] // TODO: remove this line + #[allow(dead_code)] // TODO: remove this line by actually using it async fn new( target_user_uri: String, comment: String, ) -> Result { Ok(Self { - r#type: ApObject::Flag, + r#type: Activity::Flag, actor: user::local_uri(&internal_actor::instance::get().await?.id), content: comment, object: target_user_uri, diff --git a/packages/backend-rs/src/federation/activitypub/object/follow.rs b/packages/backend-rs/src/federation/activitypub/object/follow.rs index f5954a9c55..8ac67ee243 100644 --- a/packages/backend-rs/src/federation/activitypub/object/follow.rs +++ b/packages/backend-rs/src/federation/activitypub/object/follow.rs @@ -4,12 +4,12 @@ use crate::{config::CONFIG, federation::internal_actor, misc::user}; #[macros::export(object)] pub struct ApFollow { pub id: String, - pub r#type: ApObject, + pub r#type: Activity, pub actor: String, pub object: String, } -impl ActivityPubObject for ApFollow {} +impl ApObject for ApFollow {} #[macros::errors] pub enum Error { @@ -20,7 +20,7 @@ pub enum Error { } impl ApFollow { - #[allow(dead_code)] // TODO: remove this line + #[allow(dead_code)] // TODO: remove this line by actually using it fn new( follower: UserLike, followee: UserLike, @@ -30,7 +30,7 @@ impl ApFollow { id: request_id.unwrap_or_else(|| { format!("{}/follows/{}/{}", CONFIG.url, follower.id, followee.id) }), - r#type: ApObject::Follow, + r#type: Activity::Follow, actor: match user::is_local!(follower) { true => user::local_uri(follower.id), false => follower.uri.ok_or(Error::MissingFollowerUri)?, @@ -42,11 +42,11 @@ impl ApFollow { }) } - #[allow(dead_code)] // TODO: remove this line + #[allow(dead_code)] // TODO: remove this line by actually using it async fn new_relay(relay_id: String) -> Result { Ok(Self { id: format!("{}/activities/follow-relay/{}", CONFIG.url, relay_id), - r#type: ApObject::Follow, + r#type: Activity::Follow, actor: user::local_uri(internal_actor::relay::get_id().await?), object: AS_PUBLIC_URL.to_owned(), }) diff --git a/packages/backend-rs/src/federation/activitypub/object/hashtag.rs b/packages/backend-rs/src/federation/activitypub/object/hashtag.rs index 5c1fa12e53..74187508ae 100644 --- a/packages/backend-rs/src/federation/activitypub/object/hashtag.rs +++ b/packages/backend-rs/src/federation/activitypub/object/hashtag.rs @@ -4,18 +4,18 @@ use crate::config::CONFIG; #[macros::export(object)] pub struct ApHashtag { pub id: String, - pub r#type: ApObject, + pub r#type: Activity, pub name: String, } -impl ActivityPubObject for ApHashtag {} +impl ApObject for ApHashtag {} impl ApHashtag { - #[allow(dead_code)] // TODO: remove this line + #[allow(dead_code)] // TODO: remove this line by actually using it fn new(tag_name: &str) -> Self { Self { id: format!("{}/tags/{}", CONFIG.url, urlencoding::encode(tag_name)), - r#type: ApObject::Hashtag, + r#type: Activity::Hashtag, name: format!("#{}", tag_name), } } diff --git a/packages/backend-rs/src/federation/activitypub/object/like.rs b/packages/backend-rs/src/federation/activitypub/object/like.rs index ff245588e8..c17d6a10ba 100644 --- a/packages/backend-rs/src/federation/activitypub/object/like.rs +++ b/packages/backend-rs/src/federation/activitypub/object/like.rs @@ -20,17 +20,17 @@ pub enum Error { #[macros::export(object, use_nullable = false)] pub struct ApLike { pub id: String, - pub r#type: ApObject, + pub r#type: Activity, pub actor: String, pub object: String, pub content: String, pub tag: Option>, } -impl ActivityPubObject for ApLike {} +impl ApObject for ApLike {} impl ApLike { - #[allow(dead_code)] // TODO: remove this line + #[allow(dead_code)] // TODO: remove this line by actually using it async fn new(reaction: note_reaction::Model) -> Result { let db = db_conn().await?; @@ -59,7 +59,7 @@ impl ApLike { Ok(Self { id: format!("{}/likes/{}", CONFIG.url, reaction.id), - r#type: ApObject::Like, + r#type: Activity::Like, actor: user::local_uri(reaction.user_id), object: note_uri, content: reaction.reaction, diff --git a/packages/backend-rs/src/federation/activitypub/object/mention.rs b/packages/backend-rs/src/federation/activitypub/object/mention.rs index effd069bae..e18302ceff 100644 --- a/packages/backend-rs/src/federation/activitypub/object/mention.rs +++ b/packages/backend-rs/src/federation/activitypub/object/mention.rs @@ -7,18 +7,18 @@ pub struct MissingRemoteUserUri; #[macros::export(object)] pub struct ApMention { - pub r#type: ApObject, + pub r#type: Activity, pub href: String, pub name: String, } -impl ActivityPubObject for ApMention {} +impl ApObject for ApMention {} impl ApMention { - #[allow(dead_code)] // TODO: remove this line + #[allow(dead_code)] // TODO: remove this line by actually using it fn new(user: UserLike) -> Result { Ok(Self { - r#type: ApObject::Mention, + r#type: Activity::Mention, href: match user::is_local!(user) { true => user::local_uri(user.id), false => user.uri.ok_or(MissingRemoteUserUri)?, diff --git a/packages/backend-rs/src/federation/activitypub/object/mod.rs b/packages/backend-rs/src/federation/activitypub/object/mod.rs index 187b26fd97..ce958c7678 100644 --- a/packages/backend-rs/src/federation/activitypub/object/mod.rs +++ b/packages/backend-rs/src/federation/activitypub/object/mod.rs @@ -10,10 +10,10 @@ pub mod read; pub mod remove; pub mod tombstone; -pub trait ActivityPubObject {} +pub trait ApObject {} #[macros::export(string_enum)] -pub enum ApObject { +pub enum Activity { Accept, Add, Emoji, diff --git a/packages/backend-rs/src/federation/activitypub/object/read.rs b/packages/backend-rs/src/federation/activitypub/object/read.rs index 8e69b9965e..73ebcbc988 100644 --- a/packages/backend-rs/src/federation/activitypub/object/read.rs +++ b/packages/backend-rs/src/federation/activitypub/object/read.rs @@ -3,18 +3,18 @@ use crate::misc::user; #[macros::export(object)] pub struct ApRead { - pub r#type: ApObject, + pub r#type: Activity, pub actor: String, pub object: String, } -impl ActivityPubObject for ApRead {} +impl ApObject for ApRead {} impl ApRead { - #[allow(dead_code)] // TODO: remove this line + #[allow(dead_code)] // TODO: remove this line by actually using it fn new(user_id: String, message_uri: String) -> Self { Self { - r#type: ApObject::Read, + r#type: Activity::Read, actor: user::local_uri(user_id), object: message_uri, } diff --git a/packages/backend-rs/src/federation/activitypub/object/remove.rs b/packages/backend-rs/src/federation/activitypub/object/remove.rs index 42af021fca..53ff98b81a 100644 --- a/packages/backend-rs/src/federation/activitypub/object/remove.rs +++ b/packages/backend-rs/src/federation/activitypub/object/remove.rs @@ -5,22 +5,22 @@ use crate::misc::{note, user}; #[macros::export(object)] pub struct ApRemove { - pub r#type: ApObject, + pub r#type: Activity, pub actor: String, pub target: String, pub object: String, } -impl ActivityPubObject for ApRemove {} +impl ApObject for ApRemove {} impl ApRemove { - #[allow(dead_code)] // TODO: remove this line + #[allow(dead_code)] // TODO: remove this line by actually using it fn new(user_id: String, note_id: String) -> Self { let actor_uri = user::local_uri(user_id); let collection_uri = format!("{}/collections/featured", actor_uri); Self { - r#type: ApObject::Remove, + r#type: Activity::Remove, actor: actor_uri, target: collection_uri, object: note::local_uri(note_id), diff --git a/packages/backend-rs/src/federation/activitypub/object/tombstone.rs b/packages/backend-rs/src/federation/activitypub/object/tombstone.rs index cf8069b475..00d47c2436 100644 --- a/packages/backend-rs/src/federation/activitypub/object/tombstone.rs +++ b/packages/backend-rs/src/federation/activitypub/object/tombstone.rs @@ -4,17 +4,17 @@ use crate::misc::note; #[macros::export(object)] pub struct ApTombstone { pub id: String, - pub r#type: ApObject, + pub r#type: Activity, } -impl ActivityPubObject for ApTombstone {} +impl ApObject for ApTombstone {} impl ApTombstone { - #[allow(dead_code)] // TODO: remove this line + #[allow(dead_code)] // TODO: remove this line by actually using it fn new(note_id: String) -> Self { Self { id: note::local_uri(note_id), - r#type: ApObject::Tombstone, + r#type: Activity::Tombstone, } } }