From df005a28f8db1e38a710fdddf3ba3887375bb22f Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Tue, 3 May 2022 01:26:15 +0900 Subject: [PATCH] Rename: activity07() -> activity() --- plume-common/src/activity_pub/inbox.rs | 34 ++++++-------------------- plume-models/src/blogs.rs | 8 +++--- plume-models/src/comments.rs | 20 +++++++-------- plume-models/src/follows.rs | 12 ++++----- plume-models/src/likes.rs | 12 ++++----- plume-models/src/mentions.rs | 12 ++++----- plume-models/src/posts.rs | 34 +++++++++++++------------- plume-models/src/reshares.rs | 12 ++++----- plume-models/src/tags.rs | 12 ++++----- plume-models/src/timeline/mod.rs | 5 +--- plume-models/src/users.rs | 20 +++++++-------- src/api/posts.rs | 4 +-- src/routes/blogs.rs | 2 +- src/routes/comments.rs | 6 ++--- src/routes/instance.rs | 2 +- src/routes/likes.rs | 2 +- src/routes/posts.rs | 17 ++++++------- src/routes/reshares.rs | 2 +- src/routes/user.rs | 6 ++--- 19 files changed, 99 insertions(+), 123 deletions(-) diff --git a/plume-common/src/activity_pub/inbox.rs b/plume-common/src/activity_pub/inbox.rs index 2a6d53fb..fd89fa40 100644 --- a/plume-common/src/activity_pub/inbox.rs +++ b/plume-common/src/activity_pub/inbox.rs @@ -260,7 +260,7 @@ where }; // Handle the activity - match obj.activity07(ctx, actor, act_id) { + match obj.activity(ctx, actor, act_id) { Ok(res) => Self::Handled(res.into()), Err(e) => Self::Failed(e), } @@ -540,7 +540,7 @@ where /// - `ctx`: the context passed to `Inbox::handle` /// - `actor`: the actor who did this activity /// - `id`: the ID of this activity - fn activity07(self, ctx: C, actor: A, id: &str) -> Result; + fn activity(self, ctx: C, actor: A, id: &str) -> Result; } #[cfg(test)] @@ -650,12 +650,7 @@ mod tests { type Error = (); type Output = (); - fn activity07( - self, - _: &(), - _actor: MyActor, - _id: &str, - ) -> Result { + fn activity(self, _: &(), _actor: MyActor, _id: &str) -> Result { println!("MyActor is creating a Note"); Ok(()) } @@ -665,12 +660,7 @@ mod tests { type Error = (); type Output = (); - fn activity07( - self, - _: &(), - _actor: MyActor, - _id: &str, - ) -> Result { + fn activity(self, _: &(), _actor: MyActor, _id: &str) -> Result { println!("MyActor is liking a Note"); Ok(()) } @@ -680,12 +670,7 @@ mod tests { type Error = (); type Output = (); - fn activity07( - self, - _: &(), - _actor: MyActor, - _id: &str, - ) -> Result { + fn activity(self, _: &(), _actor: MyActor, _id: &str) -> Result { println!("MyActor is deleting a Note"); Ok(()) } @@ -695,12 +680,7 @@ mod tests { type Error = (); type Output = (); - fn activity07( - self, - _: &(), - _actor: MyActor, - _id: &str, - ) -> Result { + fn activity(self, _: &(), _actor: MyActor, _id: &str) -> Result { println!("MyActor is announcing a Note"); Ok(()) } @@ -802,7 +782,7 @@ mod tests { type Error = (); type Output = (); - fn activity07( + fn activity( self, _: &(), _actor: FailingActor, diff --git a/plume-models/src/blogs.rs b/plume-models/src/blogs.rs index a08ac0f5..4deb71c6 100644 --- a/plume-models/src/blogs.rs +++ b/plume-models/src/blogs.rs @@ -160,7 +160,7 @@ impl Blog { }) } - pub fn to_activity07(&self, conn: &Connection) -> Result { + pub fn to_activity(&self, conn: &Connection) -> Result { let mut blog = ApActor::new(self.inbox_url.parse()?, Group::new()); blog.set_preferred_username(self.actor_id.clone()); blog.set_name(self.title.clone()); @@ -954,7 +954,7 @@ pub(crate) mod tests { .id, ); let _: Blog = blogs[0].save_changes(&**conn).unwrap(); - let ap_repr = blogs[0].to_activity07(&conn).unwrap(); + let ap_repr = blogs[0].to_activity(&conn).unwrap(); blogs[0].delete(&conn).unwrap(); let blog = Blog::from_activity(&conn, ap_repr).unwrap(); @@ -976,12 +976,12 @@ pub(crate) mod tests { } #[test] - fn to_activity07() { + fn to_activity() { let conn = &db(); conn.test_transaction::<_, Error, _>(|| { let (_users, blogs) = fill_database(&conn); let blog = &blogs[0]; - let act = blog.to_activity07(conn)?; + let act = blog.to_activity(conn)?; let expected = json!({ "icon": { diff --git a/plume-models/src/comments.rs b/plume-models/src/comments.rs index f19f4691..03944b3b 100644 --- a/plume-models/src/comments.rs +++ b/plume-models/src/comments.rs @@ -111,7 +111,7 @@ impl Comment { .unwrap_or(false) } - pub fn to_activity07(&self, conn: &DbConn) -> Result { + pub fn to_activity(&self, conn: &DbConn) -> Result { let author = User::get(conn, self.author_id)?; let (html, mentions, _hashtags) = utils::md_to_html( self.content.get().as_ref(), @@ -142,17 +142,17 @@ impl Comment { note.set_attributed_to(author.into_id().parse::()?); note.set_many_tos(to); note.set_many_tags(mentions.into_iter().filter_map(|m| { - Mention::build_activity07(conn, &m) + Mention::build_activity(conn, &m) .map(|mention| mention.into_any_base().expect("Can convert")) .ok() })); Ok(note) } - pub fn create_activity07(&self, conn: &DbConn) -> Result { + pub fn create_activity(&self, conn: &DbConn) -> Result { let author = User::get(conn, self.author_id)?; - let note = self.to_activity07(conn)?; + let note = self.to_activity(conn)?; let note_clone = note.clone(); let mut act = Create::new( @@ -358,7 +358,7 @@ impl AsObject for Comment { type Error = Error; type Output = Self; - fn activity07(self, _conn: &DbConn, _actor: User, _id: &str) -> Result { + fn activity(self, _conn: &DbConn, _actor: User, _id: &str) -> Result { // The actual creation takes place in the FromId impl Ok(self) } @@ -368,7 +368,7 @@ impl AsObject for Comment { type Error = Error; type Output = (); - fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> { + fn activity(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> { if self.author_id != actor.id { return Err(Error::Unauthorized); } @@ -458,7 +458,7 @@ mod tests { let conn = &db(); conn.test_transaction::<_, (), _>(|| { let (original_comm, posts, users, _blogs) = prepare_activity(&conn); - let act = original_comm.create_activity07(&conn).unwrap(); + let act = original_comm.create_activity(&conn).unwrap(); assert_json_eq!(to_value(&act).unwrap(), json!({ "actor": "https://plu.me/@/admin/", @@ -500,7 +500,7 @@ mod tests { }, ) .unwrap(); - let reply_act = reply.create_activity07(&conn).unwrap(); + let reply_act = reply.create_activity(&conn).unwrap(); assert_json_eq!(to_value(&reply_act).unwrap(), json!({ "actor": "https://plu.me/@/user/", @@ -544,11 +544,11 @@ mod tests { } #[test] - fn to_activity07() { + fn to_activity() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let (comment, _posts, _users, _blogs) = prepare_activity(&conn); - let act = comment.to_activity07(&conn)?; + let act = comment.to_activity(&conn)?; let expected = json!({ "attributedTo": "https://plu.me/@/admin/", diff --git a/plume-models/src/follows.rs b/plume-models/src/follows.rs index bf1268c2..c8ebe843 100644 --- a/plume-models/src/follows.rs +++ b/plume-models/src/follows.rs @@ -55,7 +55,7 @@ impl Follow { .map_err(Error::from) } - pub fn to_activity07(&self, conn: &Connection) -> Result { + pub fn to_activity(&self, conn: &Connection) -> Result { let user = User::get(conn, self.follower_id)?; let target = User::get(conn, self.following_id)?; let target_id = target.ap_url.parse::()?; @@ -158,7 +158,7 @@ impl AsObject for User { type Error = Error; type Output = Follow; - fn activity07(self, conn: &DbConn, actor: User, id: &str) -> Result { + 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 mut follow = @@ -212,7 +212,7 @@ impl AsObject for Follow { type Error = Error; type Output = (); - fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> { + fn activity(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> { let conn = conn; if self.follower_id == actor.id { diesel::delete(&self).execute(&**conn)?; @@ -297,11 +297,11 @@ mod tests { } #[test] - fn to_activity07() { + fn to_activity() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let (follow, _following, _follower, _users) = prepare_activity(&conn); - let act = follow.to_activity07(&conn)?; + let act = follow.to_activity(&conn)?; let expected = json!({ "actor": "https://plu.me/@/other/", @@ -323,7 +323,7 @@ mod tests { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let (follow, following, follower, _users) = prepare_activity(&conn); - let act = follow.build_accept07(&follower, &following, follow.to_activity07(&conn)?)?; + let act = follow.build_accept07(&follower, &following, follow.to_activity(&conn)?)?; let expected = json!({ "actor": "https://plu.me/@/user/", diff --git a/plume-models/src/likes.rs b/plume-models/src/likes.rs index 74d9ee83..b6ff9421 100644 --- a/plume-models/src/likes.rs +++ b/plume-models/src/likes.rs @@ -39,7 +39,7 @@ impl Like { find_by!(likes, find_by_ap_url, ap_url as &str); find_by!(likes, find_by_user_on_post, user_id as i32, post_id as i32); - pub fn to_activity07(&self, conn: &Connection) -> Result { + pub fn to_activity(&self, conn: &Connection) -> Result { let mut act = LikeAct::new( User::get(conn, self.user_id)?.ap_url.parse::()?, Post::get(conn, self.post_id)?.ap_url.parse::()?, @@ -73,7 +73,7 @@ impl Like { pub fn build_undo07(&self, conn: &Connection) -> Result { let mut act = Undo::new( User::get(conn, self.user_id)?.ap_url.parse::()?, - AnyBase::from_extended(self.to_activity07(conn)?)?, + AnyBase::from_extended(self.to_activity(conn)?)?, ); act.set_id(format!("{}#delete", self.ap_url).parse::()?); act.set_many_tos(vec![PUBLIC_VISIBILITY.parse::()?]); @@ -89,7 +89,7 @@ impl AsObject for Post { type Error = Error; type Output = Like; - fn activity07(self, conn: &DbConn, actor: User, id: &str) -> Result { + fn activity(self, conn: &DbConn, actor: User, id: &str) -> Result { let res = Like::insert( conn, NewLike { @@ -158,7 +158,7 @@ impl AsObject for Like { type Error = Error; type Output = (); - fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> { + fn activity(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> { if actor.id == self.user_id { diesel::delete(&self).execute(&**conn)?; @@ -193,14 +193,14 @@ mod tests { use serde_json::{json, to_value}; #[test] - fn to_activity07() { + fn to_activity() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let (posts, _users, _blogs) = fill_database(&conn); let post = &posts[0]; let user = &post.get_authors(&conn)?[0]; let like = Like::insert(&*conn, NewLike::new(post, user))?; - let act = like.to_activity07(&conn).unwrap(); + let act = like.to_activity(&conn).unwrap(); let expected = json!({ "actor": "https://plu.me/@/admin/", diff --git a/plume-models/src/mentions.rs b/plume-models/src/mentions.rs index 56697dde..dddb4250 100644 --- a/plume-models/src/mentions.rs +++ b/plume-models/src/mentions.rs @@ -60,7 +60,7 @@ impl Mention { } } - pub fn build_activity07(conn: &DbConn, ment: &str) -> Result { + pub fn build_activity(conn: &DbConn, ment: &str) -> Result { let user = User::find_by_fqn(conn, ment)?; let mut mention = link::Mention::new(); mention.set_href(user.ap_url.parse::()?); @@ -68,7 +68,7 @@ impl Mention { Ok(mention) } - pub fn to_activity07(&self, conn: &Connection) -> Result { + pub fn to_activity(&self, conn: &Connection) -> Result { let user = self.get_mentioned(conn)?; let mut mention = link::Mention::new(); mention.set_href(user.ap_url.parse::()?); @@ -157,13 +157,13 @@ mod tests { use serde_json::{json, to_value}; #[test] - fn build_activity07() { + fn build_activity() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let (_posts, users, _blogs) = fill_database(&conn); let user = &users[0]; let name = &user.username; - let act = Mention::build_activity07(&conn, name)?; + let act = Mention::build_activity(&conn, name)?; let expected = json!({ "href": "https://plu.me/@/admin/", @@ -178,7 +178,7 @@ mod tests { } #[test] - fn to_activity07() { + fn to_activity() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let (posts, users, _blogs) = fill_database(&conn); @@ -192,7 +192,7 @@ mod tests { comment_id: None, }, )?; - let act = mention.to_activity07(&conn)?; + let act = mention.to_activity(&conn)?; let expected = json!({ "href": "https://plu.me/@/admin/", diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index fd797cd9..dfa15a72 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -341,17 +341,17 @@ impl Post { })) } - pub fn to_activity07(&self, conn: &Connection) -> Result { + pub fn to_activity(&self, conn: &Connection) -> Result { let cc = self.get_receivers_urls(conn)?; let to = vec![PUBLIC_VISIBILITY.to_string()]; let mut mentions_json = Mention::list_for_post(conn, self.id)? .into_iter() - .map(|m| json!(m.to_activity07(conn).ok())) + .map(|m| json!(m.to_activity(conn).ok())) .collect::>(); let mut tags_json = Tag::for_post(conn, self.id)? .into_iter() - .map(|t| json!(t.to_activity07().ok())) + .map(|t| json!(t.to_activity().ok())) .collect::>(); mentions_json.append(&mut tags_json); @@ -415,8 +415,8 @@ impl Post { Ok(LicensedArticle::new(article, license, source)) } - pub fn create_activity07(&self, conn: &Connection) -> Result { - let article = self.to_activity07(conn)?; + pub fn create_activity(&self, conn: &Connection) -> Result { + let article = self.to_activity(conn)?; let to = article.to().ok_or(Error::MissingApProperty)?.clone(); let cc = article.cc().ok_or(Error::MissingApProperty)?.clone(); let mut act = Create::new( @@ -429,8 +429,8 @@ impl Post { Ok(act) } - pub fn update_activity07(&self, conn: &Connection) -> Result { - let article = self.to_activity07(conn)?; + pub fn update_activity(&self, conn: &Connection) -> Result { + let article = self.to_activity(conn)?; let to = article.to().ok_or(Error::MissingApProperty)?.clone(); let cc = article.cc().ok_or(Error::MissingApProperty)?.clone(); let mut act = Update::new( @@ -811,7 +811,7 @@ impl AsObject for Post { type Error = Error; type Output = Self; - fn activity07(self, _conn: &DbConn, _actor: User, _id: &str) -> Result { + fn activity(self, _conn: &DbConn, _actor: User, _id: &str) -> Result { // TODO: check that _actor is actually one of the author? Ok(self) } @@ -821,7 +821,7 @@ impl AsObject for Post { type Error = Error; type Output = (); - fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result { + fn activity(self, conn: &DbConn, actor: User, _id: &str) -> Result { let can_delete = self .get_authors(conn)? .into_iter() @@ -906,7 +906,7 @@ impl AsObject for PostUpdate { type Error = Error; type Output = (); - fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> { + fn activity(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> { let mut post = Post::from_id(conn, &self.ap_url, None, CONFIG.proxy()).map_err(|(_, e)| e)?; @@ -1062,7 +1062,7 @@ mod tests { }, ) .unwrap(); - let create = post.create_activity07(&conn).unwrap(); + let create = post.create_activity(&conn).unwrap(); post.delete(&conn).unwrap(); match inbox(&conn, serde_json::to_value(create).unwrap()).unwrap() { @@ -1081,11 +1081,11 @@ mod tests { } #[test] - fn to_activity07() { + fn to_activity() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let (post, _mention, _posts, _users, _blogs) = prepare_activity(&conn); - let act = post.to_activity07(&conn)?; + let act = post.to_activity(&conn)?; let expected = json!({ "attributedTo": ["https://plu.me/@/admin/", "https://plu.me/~/BlogName/"], @@ -1119,11 +1119,11 @@ mod tests { } #[test] - fn create_activity07() { + fn create_activity() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let (post, _mention, _posts, _users, _blogs) = prepare_activity(&conn); - let act = post.create_activity07(&conn)?; + let act = post.create_activity(&conn)?; let expected = json!({ "actor": "https://plu.me/@/admin/", @@ -1164,11 +1164,11 @@ mod tests { } #[test] - fn update_activity07() { + fn update_activity() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let (post, _mention, _posts, _users, _blogs) = prepare_activity(&conn); - let act = post.update_activity07(&conn)?; + let act = post.update_activity(&conn)?; let expected = json!({ "actor": "https://plu.me/@/admin/", diff --git a/plume-models/src/reshares.rs b/plume-models/src/reshares.rs index f169aa66..e0d973ab 100644 --- a/plume-models/src/reshares.rs +++ b/plume-models/src/reshares.rs @@ -65,7 +65,7 @@ impl Reshare { User::get(conn, self.user_id) } - pub fn to_activity07(&self, conn: &Connection) -> Result { + pub fn to_activity(&self, conn: &Connection) -> Result { let mut act = Announce::new( User::get(conn, self.user_id)?.ap_url.parse::()?, Post::get(conn, self.post_id)?.ap_url.parse::()?, @@ -100,7 +100,7 @@ impl Reshare { pub fn build_undo07(&self, conn: &Connection) -> Result { let mut act = Undo::new( User::get(conn, self.user_id)?.ap_url.parse::()?, - AnyBase::from_extended(self.to_activity07(conn)?)?, + AnyBase::from_extended(self.to_activity(conn)?)?, ); act.set_id(format!("{}#delete", self.ap_url).parse::()?); act.set_many_tos(vec![PUBLIC_VISIBILITY.parse::()?]); @@ -117,7 +117,7 @@ impl AsObject for Post { type Error = Error; type Output = Reshare; - fn activity07(self, conn: &DbConn, actor: User, id: &str) -> Result { + fn activity(self, conn: &DbConn, actor: User, id: &str) -> Result { let conn = conn; let reshare = Reshare::insert( conn, @@ -187,7 +187,7 @@ impl AsObject for Reshare { type Error = Error; type Output = (); - fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> { + fn activity(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> { if actor.id == self.user_id { diesel::delete(&self).execute(&**conn)?; @@ -223,14 +223,14 @@ mod test { use serde_json::{json, to_value}; #[test] - fn to_activity07() { + fn to_activity() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let (posts, _users, _blogs) = fill_database(&conn); let post = &posts[0]; let user = &post.get_authors(&conn)?[0]; let reshare = Reshare::insert(&*conn, NewReshare::new(post, user))?; - let act = reshare.to_activity07(&conn).unwrap(); + let act = reshare.to_activity(&conn).unwrap(); let expected = json!({ "actor": "https://plu.me/@/admin/", diff --git a/plume-models/src/tags.rs b/plume-models/src/tags.rs index 2bf35edc..681de5e1 100644 --- a/plume-models/src/tags.rs +++ b/plume-models/src/tags.rs @@ -25,7 +25,7 @@ impl Tag { find_by!(tags, find_by_name, tag as &str); list_by!(tags, for_post, post_id as i32); - pub fn to_activity07(&self) -> Result { + pub fn to_activity(&self) -> Result { let mut ht = Hashtag::new(); ht.set_href( ap_url(&format!( @@ -55,7 +55,7 @@ impl Tag { ) } - pub fn build_activity07(tag: String) -> Result { + pub fn build_activity(tag: String) -> Result { let mut ht = Hashtag::new(); ht.set_href( ap_url(&format!( @@ -104,7 +104,7 @@ mod tests { } #[test] - fn to_activity07() { + fn to_activity() { let conn = &db(); conn.test_transaction::<_, Error, _>(|| { fill_database(conn); @@ -114,7 +114,7 @@ mod tests { is_hashtag: false, post_id: 0, }; - let act = tag.to_activity07()?; + let act = tag.to_activity()?; let expected = json!({ "href": "https://plu.me/tag/a_tag", "name": "a_tag", @@ -128,11 +128,11 @@ mod tests { } #[test] - fn build_activity07() { + fn build_activity() { let conn = &db(); conn.test_transaction::<_, Error, _>(|| { fill_database(conn); - let act = Tag::build_activity07("a_tag".into())?; + let act = Tag::build_activity("a_tag".into())?; let expected = json!({ "href": "https://plu.me/tag/a_tag", "name": "a_tag", diff --git a/plume-models/src/timeline/mod.rs b/plume-models/src/timeline/mod.rs index db7e3602..6507f293 100644 --- a/plume-models/src/timeline/mod.rs +++ b/plume-models/src/timeline/mod.rs @@ -623,10 +623,7 @@ mod tests { ) .unwrap(); gnu_post - .update_tags07( - &conn, - vec![Tag::build_activity07("free".to_owned()).unwrap()], - ) + .update_tags07(&conn, vec![Tag::build_activity("free".to_owned()).unwrap()]) .unwrap(); PostAuthor::insert( &conn, diff --git a/plume-models/src/users.rs b/plume-models/src/users.rs index d2e3ab1b..1ea5afdb 100644 --- a/plume-models/src/users.rs +++ b/plume-models/src/users.rs @@ -611,7 +611,7 @@ impl User { Ok(posts .into_iter() .filter_map(|p| { - p.create_activity07(conn) + p.create_activity(conn) .ok() .and_then(|a| serde_json::to_value(a).ok()) }) @@ -775,7 +775,7 @@ impl User { } } - pub fn to_activity07(&self, conn: &Connection) -> Result { + pub fn to_activity(&self, conn: &Connection) -> Result { let mut actor = ApActor::new(self.inbox_url.parse()?, Person::new()); let ap_url = self.ap_url.parse::()?; actor.set_id(ap_url.clone()); @@ -813,7 +813,7 @@ impl User { Ok(CustomPerson::new(actor, ap_signature)) } - pub fn delete_activity07(&self, conn: &Connection) -> Result { + pub fn delete_activity(&self, conn: &Connection) -> Result { let mut tombstone = Tombstone::new(); tombstone.set_id(self.ap_url.parse()?); @@ -1069,7 +1069,7 @@ impl AsObject for User { type Error = Error; type Output = (); - fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> { + fn activity(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> { if self.id == actor.id { self.delete(conn).map(|_| ()) } else { @@ -1426,7 +1426,7 @@ pub(crate) mod tests { conn.test_transaction::<_, (), _>(|| { let users = fill_database(&conn); - let ap_repr = users[0].to_activity07(&conn).unwrap(); + let ap_repr = users[0].to_activity(&conn).unwrap(); users[0].delete(&conn).unwrap(); let user = User::from_activity(&conn, ap_repr).unwrap(); @@ -1447,12 +1447,12 @@ pub(crate) mod tests { } #[test] - fn to_activity07() { + fn to_activity() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let users = fill_database(&conn); let user = &users[0]; - let act = user.to_activity07(&conn)?; + let act = user.to_activity(&conn)?; let expected = json!({ "endpoints": { @@ -1477,7 +1477,7 @@ pub(crate) mod tests { assert_json_eq!(to_value(act)?, expected); let other = &users[2]; - let other_act = other.to_activity07(&conn)?; + let other_act = other.to_activity(&conn)?; let expected_other = json!({ "endpoints": { "sharedInbox": "https://plu.me/inbox" @@ -1509,12 +1509,12 @@ pub(crate) mod tests { } #[test] - fn delete_activity07() { + fn delete_activity() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let users = fill_database(&conn); let user = &users[1]; - let act = user.delete_activity07(&conn)?; + let act = user.delete_activity(&conn)?; let expected = json!({ "actor": "https://plu.me/@/user/", diff --git a/src/api/posts.rs b/src/api/posts.rs index d08d8d6a..56c80da9 100644 --- a/src/api/posts.rs +++ b/src/api/posts.rs @@ -193,14 +193,14 @@ pub fn create( for m in mentions.into_iter() { Mention::from_activity( &conn, - &Mention::build_activity07(&conn, &m)?, + &Mention::build_activity(&conn, &m)?, post.id, true, true, )?; } - let act = post.create_activity07(&conn)?; + let act = post.create_activity(&conn)?; let dest = User::one_by_instance(&conn)?; worker.execute(move || broadcast(&author, act, dest, CONFIG.proxy().cloned())); } diff --git a/src/routes/blogs.rs b/src/routes/blogs.rs index 1135d9ed..9ec851c0 100644 --- a/src/routes/blogs.rs +++ b/src/routes/blogs.rs @@ -49,7 +49,7 @@ pub fn activity_details( _ap: ApRequest, ) -> Option> { let blog = Blog::find_by_fqn(&conn, &name).ok()?; - Some(ActivityStream::new(blog.to_activity07(&conn).ok()?)) + Some(ActivityStream::new(blog.to_activity(&conn).ok()?)) } #[get("/blogs/new")] diff --git a/src/routes/comments.rs b/src/routes/comments.rs index 5fd2cbcc..91a1ab0a 100644 --- a/src/routes/comments.rs +++ b/src/routes/comments.rs @@ -66,14 +66,14 @@ pub fn create( ) .expect("comments::create: insert error"); let new_comment = comm - .create_activity07(&conn) + .create_activity(&conn) .expect("comments::create: activity error"); // save mentions for ment in mentions { Mention::from_activity( &conn, - &Mention::build_activity07(&conn, &ment) + &Mention::build_activity(&conn, &ment) .expect("comments::create: build mention error"), comm.id, false, @@ -187,7 +187,7 @@ pub fn activity_pub( conn: DbConn, ) -> Option> { Comment::get(&conn, id) - .and_then(|c| c.to_activity07(&conn)) + .and_then(|c| c.to_activity(&conn)) .ok() .map(ActivityStream::new) } diff --git a/src/routes/instance.rs b/src/routes/instance.rs index 06cf63cd..cedaa900 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -382,7 +382,7 @@ fn ban(id: i32, conn: &Connection, worker: &ScheduledThreadPool) -> Result<(), E ) .unwrap(); let target = User::one_by_instance(&*conn)?; - let delete_act = u.delete_activity07(&*conn)?; + let delete_act = u.delete_activity(&*conn)?; worker.execute(move || broadcast(&u, delete_act, target, CONFIG.proxy().cloned())); } diff --git a/src/routes/likes.rs b/src/routes/likes.rs index fc1c2970..cf141cb7 100644 --- a/src/routes/likes.rs +++ b/src/routes/likes.rs @@ -27,7 +27,7 @@ pub fn create( Timeline::add_to_all_timelines(&conn, &post, Kind::Like(&user))?; let dest = User::one_by_instance(&*conn)?; - let act = like.to_activity07(&*conn)?; + let act = like.to_activity(&*conn)?; rockets .worker .execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned())); diff --git a/src/routes/posts.rs b/src/routes/posts.rs index 39209824..adb5d06c 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -113,7 +113,7 @@ pub fn activity_details( let post = Post::find_by_slug(&conn, &slug, blog.id).map_err(|_| None)?; if post.published { Ok(ActivityStream::new( - post.to_activity07(&conn) + post.to_activity(&conn) .map_err(|_| String::from("Post serialization error"))?, )) } else { @@ -312,7 +312,7 @@ pub fn update( &conn, mentions .into_iter() - .filter_map(|m| Mention::build_activity07(&conn, &m).ok()) + .filter_map(|m| Mention::build_activity(&conn, &m).ok()) .collect(), ) .expect("post::update: mentions error"); @@ -325,7 +325,7 @@ pub fn update( .filter(|t| !t.is_empty()) .collect::>() .into_iter() - .filter_map(|t| Tag::build_activity07(t.to_string()).ok()) + .filter_map(|t| Tag::build_activity(t.to_string()).ok()) .collect::>(); post.update_tags07(&conn, tags) .expect("post::update: tags error"); @@ -334,7 +334,7 @@ pub fn update( .into_iter() .collect::>() .into_iter() - .filter_map(|t| Tag::build_activity07(t).ok()) + .filter_map(|t| Tag::build_activity(t).ok()) .collect::>(); post.update_hashtags07(&conn, hashtags) .expect("post::update: hashtags error"); @@ -342,7 +342,7 @@ pub fn update( if post.published { if newly_published { let act = post - .create_activity07(&conn) + .create_activity(&conn) .expect("post::update: act error"); let dest = User::one_by_instance(&conn).expect("post::update: dest error"); rockets @@ -352,7 +352,7 @@ pub fn update( Timeline::add_to_all_timelines(&conn, &post, Kind::Original).ok(); } else { let act = post - .update_activity07(&conn) + .update_activity(&conn) .expect("post::update: act error"); let dest = User::one_by_instance(&conn).expect("posts::update: dest error"); rockets @@ -532,8 +532,7 @@ pub fn create( for m in mentions { Mention::from_activity( &conn, - &Mention::build_activity07(&conn, &m) - .expect("post::create: mention build error"), + &Mention::build_activity(&conn, &m).expect("post::create: mention build error"), post.id, true, true, @@ -542,7 +541,7 @@ pub fn create( } let act = post - .create_activity07(&conn) + .create_activity(&conn) .expect("posts::create: activity error"); let dest = User::one_by_instance(&conn).expect("posts::create: dest error"); let worker = &rockets.worker; diff --git a/src/routes/reshares.rs b/src/routes/reshares.rs index e815486b..120673d5 100644 --- a/src/routes/reshares.rs +++ b/src/routes/reshares.rs @@ -27,7 +27,7 @@ pub fn create( Timeline::add_to_all_timelines(&conn, &post, Kind::Reshare(&user))?; let dest = User::one_by_instance(&conn)?; - let act = reshare.to_activity07(&conn)?; + let act = reshare.to_activity(&conn)?; rockets .worker .execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned())); diff --git a/src/routes/user.rs b/src/routes/user.rs index 259aaf4d..b9e836bb 100644 --- a/src/routes/user.rs +++ b/src/routes/user.rs @@ -125,7 +125,7 @@ pub fn follow( )?; f.notify(&conn)?; - let act = f.to_activity07(&conn)?; + let act = f.to_activity(&conn)?; let msg = i18n!(rockets.intl.catalog, "You are now following {}."; target.name()); rockets .worker @@ -271,7 +271,7 @@ pub fn activity_details( _ap: ApRequest, ) -> Option> { let user = User::find_by_fqn(&conn, &name).ok()?; - Some(ActivityStream::new(user.to_activity07(&conn).ok()?)) + Some(ActivityStream::new(user.to_activity(&conn).ok()?)) } #[get("/users/new")] @@ -386,7 +386,7 @@ pub fn delete( account.delete(&conn)?; let target = User::one_by_instance(&conn)?; - let delete_act = account.delete_activity07(&conn)?; + let delete_act = account.delete_activity(&conn)?; rockets .worker .execute(move || broadcast(&account, delete_act, target, CONFIG.proxy().cloned()));