diff --git a/plume-models/src/blogs.rs b/plume-models/src/blogs.rs index 4deb71c6..ac20ee86 100644 --- a/plume-models/src/blogs.rs +++ b/plume-models/src/blogs.rs @@ -221,10 +221,10 @@ impl Blog { Ok(CustomGroup::new(blog, ap_signature, source)) } - pub fn outbox07(&self, conn: &Connection) -> Result> { - self.outbox_collection07(conn).map(ActivityStream::new) + pub fn outbox(&self, conn: &Connection) -> Result> { + self.outbox_collection(conn).map(ActivityStream::new) } - pub fn outbox_collection07(&self, conn: &Connection) -> Result { + pub fn outbox_collection(&self, conn: &Connection) -> Result { let acts = self.get_activities(conn); let acts = acts .iter() @@ -245,15 +245,15 @@ impl Blog { ); Ok(coll) } - pub fn outbox_page07( + pub fn outbox_page( &self, conn: &Connection, (min, max): (i32, i32), ) -> Result> { - self.outbox_collection_page07(conn, (min, max)) + self.outbox_collection_page(conn, (min, max)) .map(ActivityStream::new) } - pub fn outbox_collection_page07( + pub fn outbox_collection_page( &self, conn: &Connection, (min, max): (i32, i32), @@ -917,7 +917,7 @@ pub(crate) mod tests { } #[test] - fn self_federation07() { + fn self_federation() { let conn = &db(); conn.test_transaction::<_, (), _>(|| { let (users, mut blogs) = fill_database(&conn); @@ -1019,12 +1019,12 @@ pub(crate) mod tests { } #[test] - fn outbox_collection07() { + fn outbox_collection() { let conn = &db(); conn.test_transaction::<_, Error, _>(|| { let (_users, blogs) = fill_database(conn); let blog = &blogs[0]; - let act = blog.outbox_collection07(conn)?; + let act = blog.outbox_collection(conn)?; let expected = json!({ "items": [], @@ -1041,12 +1041,12 @@ pub(crate) mod tests { } #[test] - fn outbox_collection_page07() { + fn outbox_collection_page() { let conn = &db(); conn.test_transaction::<_, Error, _>(|| { let (_users, blogs) = fill_database(conn); let blog = &blogs[0]; - let act = blog.outbox_collection_page07(conn, (33, 36))?; + let act = blog.outbox_collection_page(conn, (33, 36))?; let expected = json!({ "next": "https://plu.me/~/BlogName/outbox?page=3", diff --git a/plume-models/src/comments.rs b/plume-models/src/comments.rs index 03944b3b..d928b9a3 100644 --- a/plume-models/src/comments.rs +++ b/plume-models/src/comments.rs @@ -196,7 +196,7 @@ impl Comment { Ok(()) } - pub fn build_delete07(&self, conn: &Connection) -> Result { + pub fn build_delete(&self, conn: &Connection) -> Result { let mut tombstone = Tombstone::new(); tombstone.set_id( self.ap_url @@ -454,7 +454,7 @@ mod tests { // creates a post, get it's Create activity, delete the post, // "send" the Create to the inbox, and check it works #[test] - fn self_federation07() { + fn self_federation() { let conn = &db(); conn.test_transaction::<_, (), _>(|| { let (original_comm, posts, users, _blogs) = prepare_activity(&conn); @@ -523,7 +523,7 @@ mod tests { inbox( &conn, - serde_json::to_value(original_comm.build_delete07(&conn).unwrap()).unwrap(), + serde_json::to_value(original_comm.build_delete(&conn).unwrap()).unwrap(), ) .unwrap(); @@ -576,11 +576,11 @@ mod tests { } #[test] - fn build_delete07() { + fn build_delete() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let (comment, _posts, _users, _blogs) = prepare_activity(&conn); - let act = comment.build_delete07(&conn)?; + let act = comment.build_delete(&conn)?; let expected = json!({ "actor": "https://plu.me/@/admin/", diff --git a/plume-models/src/follows.rs b/plume-models/src/follows.rs index c8ebe843..2a334767 100644 --- a/plume-models/src/follows.rs +++ b/plume-models/src/follows.rs @@ -84,7 +84,7 @@ impl Follow { /// from -> The one sending the follow request /// target -> The target of the request, responding with Accept - pub fn accept_follow07 + IntoId, T>( + pub fn accept_follow + IntoId, T>( conn: &Connection, from: &B, target: &A, @@ -105,7 +105,7 @@ impl Follow { )?; res.notify(conn)?; - let accept = res.build_accept07(from, target, follow)?; + let accept = res.build_accept(from, target, follow)?; broadcast( &*target, accept, @@ -115,7 +115,7 @@ impl Follow { Ok(res) } - pub fn build_accept07 + IntoId, T>( + pub fn build_accept + IntoId, T>( &self, from: &B, target: &A, @@ -137,7 +137,7 @@ impl Follow { Ok(accept) } - pub fn build_undo07(&self, conn: &Connection) -> Result { + pub fn build_undo(&self, conn: &Connection) -> Result { let mut undo = Undo::new( User::get(conn, self.follower_id)? .ap_url @@ -164,7 +164,7 @@ impl AsObject for User { let mut follow = FollowAct::new(id.parse::()?, actor.ap_url.parse::()?); follow.set_id(id.parse::()?); - Follow::accept_follow07(conn, &actor, &self, follow, actor.id, self.id) + Follow::accept_follow(conn, &actor, &self, follow, actor.id, self.id) } } @@ -200,7 +200,7 @@ impl FromId for Follow { CONFIG.proxy(), ) .map_err(|(_, e)| e)?; - Follow::accept_follow07(conn, &actor, &target, follow, actor.id, target.id) + Follow::accept_follow(conn, &actor, &target, follow, actor.id, target.id) } fn get_sender() -> &'static dyn Signer { @@ -319,11 +319,11 @@ mod tests { } #[test] - fn build_accept07() { + fn build_accept() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let (follow, following, follower, _users) = prepare_activity(&conn); - let act = follow.build_accept07(&follower, &following, follow.to_activity(&conn)?)?; + let act = follow.build_accept(&follower, &following, follow.to_activity(&conn)?)?; let expected = json!({ "actor": "https://plu.me/@/user/", @@ -348,11 +348,11 @@ mod tests { } #[test] - fn build_undo07() { + fn build_undo() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let (follow, _following, _follower, _users) = prepare_activity(&conn); - let act = follow.build_undo07(&conn)?; + let act = follow.build_undo(&conn)?; let expected = json!({ "actor": "https://plu.me/@/other/", diff --git a/plume-models/src/likes.rs b/plume-models/src/likes.rs index b6ff9421..b9dda167 100644 --- a/plume-models/src/likes.rs +++ b/plume-models/src/likes.rs @@ -70,7 +70,7 @@ impl Like { Ok(()) } - pub fn build_undo07(&self, conn: &Connection) -> Result { + pub fn build_undo(&self, conn: &Connection) -> Result { let mut act = Undo::new( User::get(conn, self.user_id)?.ap_url.parse::()?, AnyBase::from_extended(self.to_activity(conn)?)?, @@ -217,14 +217,14 @@ mod tests { } #[test] - fn build_undo07() { + fn build_undo() { 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.build_undo07(&*conn)?; + let act = like.build_undo(&*conn)?; let expected = json!({ "actor": "https://plu.me/@/admin/", diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index dfa15a72..58a203f7 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -445,7 +445,7 @@ impl Post { Ok(act) } - pub fn update_mentions07(&self, conn: &Connection, mentions: Vec) -> Result<()> { + pub fn update_mentions(&self, conn: &Connection, mentions: Vec) -> Result<()> { let mentions = mentions .into_iter() .map(|m| { @@ -483,7 +483,7 @@ impl Post { Ok(()) } - pub fn update_tags07(&self, conn: &Connection, tags: Vec) -> Result<()> { + pub fn update_tags(&self, conn: &Connection, tags: Vec) -> Result<()> { let tags_name = tags .iter() .filter_map(|t| t.name.as_ref().map(|name| name.as_str().to_string())) @@ -520,7 +520,7 @@ impl Post { Ok(()) } - pub fn update_hashtags07(&self, conn: &Connection, tags: Vec) -> Result<()> { + pub fn update_hashtags(&self, conn: &Connection, tags: Vec) -> Result<()> { let tags_name = tags .iter() .filter_map(|t| t.name.as_ref().map(|name| name.as_str().to_string())) @@ -568,7 +568,7 @@ impl Post { .and_then(|c| c.url().ok()) } - pub fn build_delete07(&self, conn: &Connection) -> Result { + pub fn build_delete(&self, conn: &Connection) -> Result { let mut tombstone = Tombstone::new(); tombstone.set_id(self.ap_url.parse()?); @@ -968,9 +968,9 @@ impl AsObject for PostUpdate { }) .ok(); } - post.update_mentions07(conn, mentions)?; - post.update_tags07(conn, tags)?; - post.update_hashtags07(conn, hashtags)?; + post.update_mentions(conn, mentions)?; + post.update_tags(conn, tags)?; + post.update_hashtags(conn, hashtags)?; } post.update(conn)?; @@ -1033,7 +1033,7 @@ mod tests { // creates a post, get it's Create activity, delete the post, // "send" the Create to the inbox, and check it works #[test] - fn self_federation07() { + fn self_federation() { let conn = &db(); conn.test_transaction::<_, (), _>(|| { let (_, users, blogs) = fill_database(&conn); @@ -1230,11 +1230,11 @@ mod tests { } #[test] - fn build_delete07() { + fn build_delete() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let (post, _mention, _posts, _users, _blogs) = prepare_activity(&conn); - let act = post.build_delete07(&conn)?; + let act = post.build_delete(&conn)?; let expected = json!({ "actor": "https://plu.me/@/admin/", diff --git a/plume-models/src/remote_fetch_actor.rs b/plume-models/src/remote_fetch_actor.rs index 228671e3..03f1dd76 100644 --- a/plume-models/src/remote_fetch_actor.rs +++ b/plume-models/src/remote_fetch_actor.rs @@ -68,7 +68,7 @@ impl ActorFactoryArgs for RemoteFetchActor { } fn fetch_and_cache_articles(user: &Arc, conn: &DbConn) { - let create_acts = user.fetch_outbox07::(); + let create_acts = user.fetch_outbox::(); match create_acts { Ok(create_acts) => { for create_act in create_acts { diff --git a/plume-models/src/reshares.rs b/plume-models/src/reshares.rs index e0d973ab..aec75796 100644 --- a/plume-models/src/reshares.rs +++ b/plume-models/src/reshares.rs @@ -97,7 +97,7 @@ impl Reshare { Ok(()) } - pub fn build_undo07(&self, conn: &Connection) -> Result { + pub fn build_undo(&self, conn: &Connection) -> Result { let mut act = Undo::new( User::get(conn, self.user_id)?.ap_url.parse::()?, AnyBase::from_extended(self.to_activity(conn)?)?, @@ -247,14 +247,14 @@ mod test { } #[test] - fn build_undo07() { + fn build_undo() { 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.build_undo07(&*conn)?; + let act = reshare.build_undo(&*conn)?; let expected = json!({ "actor": "https://plu.me/@/admin/", diff --git a/plume-models/src/timeline/mod.rs b/plume-models/src/timeline/mod.rs index 6507f293..d6b2a59d 100644 --- a/plume-models/src/timeline/mod.rs +++ b/plume-models/src/timeline/mod.rs @@ -623,7 +623,7 @@ mod tests { ) .unwrap(); gnu_post - .update_tags07(&conn, vec![Tag::build_activity("free".to_owned()).unwrap()]) + .update_tags(&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 1ea5afdb..3086b7a8 100644 --- a/plume-models/src/users.rs +++ b/plume-models/src/users.rs @@ -460,10 +460,10 @@ impl User { .load::(conn) .map_err(Error::from) } - pub fn outbox07(&self, conn: &Connection) -> Result> { - Ok(ActivityStream::new(self.outbox_collection07(conn)?)) + pub fn outbox(&self, conn: &Connection) -> Result> { + Ok(ActivityStream::new(self.outbox_collection(conn)?)) } - pub fn outbox_collection07(&self, conn: &Connection) -> Result { + pub fn outbox_collection(&self, conn: &Connection) -> Result { let mut coll = OrderedCollection::new(); let first = &format!("{}?page=1", &self.outbox_url); let last = &format!( @@ -476,16 +476,16 @@ impl User { coll.set_total_items(self.get_activities_count(conn) as u64); Ok(coll) } - pub fn outbox_page07( + pub fn outbox_page( &self, conn: &Connection, (min, max): (i32, i32), ) -> Result> { Ok(ActivityStream::new( - self.outbox_collection_page07(conn, (min, max))?, + self.outbox_collection_page(conn, (min, max))?, )) } - pub fn outbox_collection_page07( + pub fn outbox_collection_page( &self, conn: &Connection, (min, max): (i32, i32), @@ -513,7 +513,7 @@ impl User { Ok(coll) } - pub fn fetch_outbox_page07( + pub fn fetch_outbox_page( &self, url: &str, ) -> Result<(Vec, Option)> { @@ -531,7 +531,7 @@ impl User { Ok((items, next)) } - pub fn fetch_outbox07(&self) -> Result> { + pub fn fetch_outbox(&self) -> Result> { let mut res = get( &self.outbox_url[..], Self::get_sender(), @@ -542,7 +542,7 @@ impl User { if let Some(first) = json.get("first") { let mut items: Vec = Vec::new(); let mut next = first.as_str().unwrap().to_owned(); - while let Ok((mut page, nxt)) = self.fetch_outbox_page07(&next) { + while let Ok((mut page, nxt)) = self.fetch_outbox_page(&next) { if page.is_empty() { break; } @@ -1421,7 +1421,7 @@ pub(crate) mod tests { } #[test] - fn self_federation07() { + fn self_federation() { let conn = db(); conn.test_transaction::<_, (), _>(|| { let users = fill_database(&conn); @@ -1535,12 +1535,12 @@ pub(crate) mod tests { } #[test] - fn outbox_collection07() { + fn outbox_collection() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let (_pages, users, _blogs) = fill_pages(&conn); let user = &users[0]; - let act = user.outbox_collection07(&conn)?; + let act = user.outbox_collection(&conn)?; let expected = json!({ "first": "https://plu.me/@/admin/outbox?page=1", @@ -1556,12 +1556,12 @@ pub(crate) mod tests { } #[test] - fn outbox_collection_page07() { + fn outbox_collection_page() { let conn = db(); conn.test_transaction::<_, Error, _>(|| { let users = fill_database(&conn); let user = &users[0]; - let act = user.outbox_collection_page07(&conn, (33, 36))?; + let act = user.outbox_collection_page(&conn, (33, 36))?; let expected = json!({ "items": [], diff --git a/src/routes/blogs.rs b/src/routes/blogs.rs index 9ec851c0..7359779a 100644 --- a/src/routes/blogs.rs +++ b/src/routes/blogs.rs @@ -349,7 +349,7 @@ pub fn update( #[get("/~//outbox")] pub fn outbox(name: String, conn: DbConn) -> Option> { let blog = Blog::find_by_fqn(&conn, &name).ok()?; - blog.outbox07(&conn).ok() + blog.outbox(&conn).ok() } #[allow(unused_variables)] #[get("/~//outbox?")] @@ -359,7 +359,7 @@ pub fn outbox_page( conn: DbConn, ) -> Option> { let blog = Blog::find_by_fqn(&conn, &name).ok()?; - blog.outbox_page07(&conn, page.limits()).ok() + blog.outbox_page(&conn, page.limits()).ok() } #[get("/~//atom.xml")] pub fn atom_feed(name: String, conn: DbConn) -> Option> { diff --git a/src/routes/comments.rs b/src/routes/comments.rs index 91a1ab0a..5f60aae3 100644 --- a/src/routes/comments.rs +++ b/src/routes/comments.rs @@ -150,7 +150,7 @@ pub fn delete( if let Ok(comment) = Comment::get(&conn, id) { if comment.author_id == user.id { let dest = User::one_by_instance(&conn)?; - let delete_activity = comment.build_delete07(&conn)?; + let delete_activity = comment.build_delete(&conn)?; inbox( &conn, serde_json::to_value(&delete_activity).map_err(Error::from)?, diff --git a/src/routes/likes.rs b/src/routes/likes.rs index cf141cb7..25ca68bf 100644 --- a/src/routes/likes.rs +++ b/src/routes/likes.rs @@ -33,7 +33,7 @@ pub fn create( .execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned())); } else { let like = likes::Like::find_by_user_on_post(&conn, user.id, post.id)?; - let delete_act = like.build_undo07(&conn)?; + let delete_act = like.build_undo(&conn)?; inbox( &conn, serde_json::to_value(&delete_act).map_err(Error::from)?, diff --git a/src/routes/posts.rs b/src/routes/posts.rs index adb5d06c..5d498f8c 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -308,7 +308,7 @@ pub fn update( post.update(&conn).expect("post::update: update error"); if post.published { - post.update_mentions07( + post.update_mentions( &conn, mentions .into_iter() @@ -327,7 +327,7 @@ pub fn update( .into_iter() .filter_map(|t| Tag::build_activity(t.to_string()).ok()) .collect::>(); - post.update_tags07(&conn, tags) + post.update_tags(&conn, tags) .expect("post::update: tags error"); let hashtags = hashtags @@ -336,7 +336,7 @@ pub fn update( .into_iter() .filter_map(|t| Tag::build_activity(t).ok()) .collect::>(); - post.update_hashtags07(&conn, hashtags) + post.update_hashtags(&conn, hashtags) .expect("post::update: hashtags error"); if post.published { @@ -606,7 +606,7 @@ pub fn delete( } let dest = User::one_by_instance(&conn)?; - let delete_activity = post.build_delete07(&conn)?; + let delete_activity = post.build_delete(&conn)?; inbox( &conn, serde_json::to_value(&delete_activity).map_err(Error::from)?, diff --git a/src/routes/reshares.rs b/src/routes/reshares.rs index 120673d5..b6d11c8a 100644 --- a/src/routes/reshares.rs +++ b/src/routes/reshares.rs @@ -33,7 +33,7 @@ pub fn create( .execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned())); } else { let reshare = Reshare::find_by_user_on_post(&conn, user.id, post.id)?; - let delete_act = reshare.build_undo07(&conn)?; + let delete_act = reshare.build_undo(&conn)?; inbox( &conn, serde_json::to_value(&delete_act).map_err(Error::from)?, diff --git a/src/routes/user.rs b/src/routes/user.rs index b9e836bb..443cb151 100644 --- a/src/routes/user.rs +++ b/src/routes/user.rs @@ -103,7 +103,7 @@ pub fn follow( ) -> Result, ErrorPage> { let target = User::find_by_fqn(&conn, &name)?; let message = if let Ok(follow) = follows::Follow::find(&conn, user.id, target.id) { - let delete_act = follow.build_undo07(&conn)?; + let delete_act = follow.build_undo(&conn)?; local_inbox( &conn, serde_json::to_value(&delete_act).map_err(Error::from)?, @@ -531,7 +531,7 @@ pub fn create( #[get("/@//outbox")] pub fn outbox(name: String, conn: DbConn) -> Option> { let user = User::find_by_fqn(&conn, &name).ok()?; - user.outbox07(&conn).ok() + user.outbox(&conn).ok() } #[get("/@//outbox?")] pub fn outbox_page( @@ -540,7 +540,7 @@ pub fn outbox_page( conn: DbConn, ) -> Option> { let user = User::find_by_fqn(&conn, &name).ok()?; - user.outbox_page07(&conn, page.limits()).ok() + user.outbox_page(&conn, page.limits()).ok() } #[post("/@//inbox", data = "")] pub fn inbox(