diff --git a/plume-models/src/comments.rs b/plume-models/src/comments.rs index d39f1ec6..82b35635 100644 --- a/plume-models/src/comments.rs +++ b/plume-models/src/comments.rs @@ -14,11 +14,11 @@ use crate::{ use activitystreams::{ activity::{Create, Delete}, base::{AnyBase, Base}, - link, + iri, link, object::{Note, ObjectExt}, prelude::*, primitives::OneOrMany, - public, uri as as_uri, + public, }; use chrono::{self, NaiveDateTime}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl}; @@ -152,8 +152,8 @@ impl Comment { let note = self.to_activity(&*conn)?; let base = Base::retract(note)?.into_generic()?; let any_base = AnyBase::from_base(base); - let act = Create::new::>( - as_uri!(author.ap_url), + let act = Create::new::<_, OneOrMany>( + iri!(author.ap_url), OneOrMany::from_one(any_base), ); // let mut act = Create::default(); @@ -195,7 +195,7 @@ impl Comment { let base = Base::retract(comment)?.into_generic()?; let any_base = AnyBase::from_base(base); let act = Delete::new( - as_uri!(User::get(conn, self.author_id)?.ap_url), // FIXME + iri!(User::get(conn, self.author_id)?.ap_url), // FIXME OneOrMany::from_one(any_base), ); // let mut act = Delete::default(); @@ -278,10 +278,7 @@ impl FromId for Comment { .to_string() }) .unwrap_or_default(), - ap_url: note - .id(&Instance::get_local()?.public_domain) - .expect("authorized domain") - .map(|url| url.to_string()), + ap_url: note.id().map(|url| url.to_string()), in_response_to_id: previous_comment.iter().map(|c| c.id).next(), post_id: previous_comment.map(|c| c.post_id).or_else(|_| { Ok(Post::find_by_ap_url(conn, previous_url)?.id) as Result diff --git a/plume-models/src/follows.rs b/plume-models/src/follows.rs index f8b8d232..33bf39de 100644 --- a/plume-models/src/follows.rs +++ b/plume-models/src/follows.rs @@ -5,8 +5,8 @@ use crate::{ use activitystreams::{ activity::{Accept, ActivityExt, ActorAndObjectRefExt, AsActivity, Follow as FollowAct, Undo}, base::AnyBase, + iri, primitives::OneOrMany, - uri as as_uri, }; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl}; use plume_common::activity_pub::{ @@ -60,8 +60,8 @@ impl Follow { let target = User::get(conn, self.following_id)?; let act = FollowAct::new( - as_uri!(user.ap_url), // FIXME: Use to_activity() - as_uri!(target.ap_url), // FIXME: Use to_activity() + iri!(user.ap_url), // FIXME: Use to_activity() + iri!(target.ap_url), // FIXME: Use to_activity() ); // let mut act = FollowAct::default(); @@ -130,8 +130,8 @@ impl Follow { follow: FollowAct, ) -> Result { let accept = Accept::new( - as_uri!(target.into_id()), // FIXME: Use to_activity() - as_uri!(from.into_id()), // FIXME: Use to_activity() + iri!(target.into_id()), // FIXME: Use to_activity() + iri!(from.into_id()), // FIXME: Use to_activity() ); // let mut accept = Accept::default(); @@ -157,12 +157,8 @@ impl Follow { pub fn build_undo(&self, conn: &Connection) -> Result { let follow = self.to_activity(conn)?; - let undo = Undo::new::>( - *follow - .actor() - .expect("authorized domain") - .as_single_id() - .expect("exists and only"), + let undo = Undo::new::<_, OneOrMany>( + *follow.actor().as_single_id().expect("exists and only"), *follow.result().expect("exists"), ); // let mut undo = Undo::default(); @@ -187,7 +183,7 @@ impl AsObject for User { fn activity(self, conn: &DbConn, actor: User, id: &str) -> Result { // Mastodon (at least) requires the full Follow object when accepting it, // so we rebuilt it here - let follow = FollowAct::new(as_uri!(actor.ap_url), as_uri!(id)); + let follow = FollowAct::new(iri!(actor.ap_url), iri!(id)); // let mut follow = FollowAct::default(); // follow.object_props.set_id_string(id.to_string())?; // follow @@ -210,7 +206,6 @@ impl FromId for Follow { conn, &follow .actor() - .expect("authorized domain") .as_single_id() .expect("exists and only") .as_str(), diff --git a/plume-models/src/likes.rs b/plume-models/src/likes.rs index c372b885..49f56c1d 100644 --- a/plume-models/src/likes.rs +++ b/plume-models/src/likes.rs @@ -5,8 +5,8 @@ use crate::{ use activitystreams::{ activity::{self, ActivityExt, ActorAndObjectRefExt}, base::AnyBase, + iri, primitives::OneOrMany, - uri as as_uri, }; use chrono::NaiveDateTime; @@ -41,8 +41,8 @@ impl Like { pub fn to_activity(&self, conn: &Connection) -> Result { let act = activity::Like::new( - as_uri!(User::get(conn, self.user_id)?.ap_url), // FIXME: use to_activity() - as_uri!(Post::get(conn, self.post_id)?.ap_url), // FIXME: use to_activity() + iri!(User::get(conn, self.user_id)?.ap_url), // FIXME: use to_activity() + iri!(Post::get(conn, self.post_id)?.ap_url), // FIXME: use to_activity() ); // let mut act = activity::Like::default(); // act.like_props @@ -78,12 +78,8 @@ impl Like { pub fn build_undo(&self, conn: &Connection) -> Result { let like = self.to_activity(conn)?; - let act = activity::Undo::new::>( - *like - .actor() - .expect("authorized domain") - .as_single_id() - .expect("exists and only"), + let act = activity::Undo::new::<_, OneOrMany>( + *like.actor().as_single_id().expect("exists and only"), *like.result().expect("exists"), ); @@ -145,11 +141,7 @@ impl FromId for Like { .id, user_id: User::from_id( conn, - &act.actor() - .expect("authorized domain") - .as_single_id() - .expect("exists") - .as_str(), + &act.actor().as_single_id().expect("exists").as_str(), None, CONFIG.proxy(), ) diff --git a/plume-models/src/reshares.rs b/plume-models/src/reshares.rs index 07dc2325..dc14e92f 100644 --- a/plume-models/src/reshares.rs +++ b/plume-models/src/reshares.rs @@ -5,8 +5,8 @@ use crate::{ use activitystreams::{ activity::{ActivityExt, ActorAndObjectRefExt, Announce, Undo}, base::AnyBase, + iri, primitives::OneOrMany, - uri as as_uri, }; use chrono::NaiveDateTime; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; @@ -66,8 +66,8 @@ impl Reshare { pub fn to_activity(&self, conn: &Connection) -> Result { let act = Announce::new( - as_uri!(User::get(conn, self.user_id)?.ap_url), // FIXME: Use to_activity() - as_uri!(Post::get(conn, self.post_id)?.ap_url), // FIXME: Use to_activity() + iri!(User::get(conn, self.user_id)?.ap_url), // FIXME: Use to_activity() + iri!(Post::get(conn, self.post_id)?.ap_url), // FIXME: Use to_activity() ); // let mut act = Announce::default(); @@ -103,12 +103,8 @@ impl Reshare { pub fn build_undo(&self, conn: &Connection) -> Result { let announce = self.to_activity(conn)?; - let act = Undo::new::>( - *announce - .actor() - .expect("authorized domain") - .as_single_id() - .expect("exists and only"), + let act = Undo::new::<_, OneOrMany>( + *announce.actor().as_single_id().expect("exists and only"), *announce.result().expect("exists"), ); @@ -173,11 +169,7 @@ impl FromId for Reshare { .id, user_id: User::from_id( conn, - &act.actor() - .expect("authorized domain") - .as_single_id() - .expect("exists") - .as_str(), + &act.actor().as_single_id().expect("exists").as_str(), None, CONFIG.proxy(), )