From 1dd176dd80b03cd5ec20af5e560f96e63c1fe129 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Tue, 3 May 2022 01:12:39 +0900 Subject: [PATCH] Rename: broadcast07() -> broadcast() --- plume-common/src/activity_pub/mod.rs | 2 +- plume-models/src/follows.rs | 4 ++-- src/api/posts.rs | 4 ++-- src/routes/comments.rs | 6 +++--- src/routes/instance.rs | 4 ++-- src/routes/likes.rs | 6 +++--- src/routes/posts.rs | 10 +++++----- src/routes/reshares.rs | 6 +++--- src/routes/user.rs | 8 ++++---- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/plume-common/src/activity_pub/mod.rs b/plume-common/src/activity_pub/mod.rs index c1ee1a4f..8310ecd1 100644 --- a/plume-common/src/activity_pub/mod.rs +++ b/plume-common/src/activity_pub/mod.rs @@ -120,7 +120,7 @@ impl<'a, 'r> FromRequest<'a, 'r> for ApRequest { } } -pub fn broadcast07(sender: &S, act: A, to: Vec, proxy: Option) +pub fn broadcast(sender: &S, act: A, to: Vec, proxy: Option) where S: sign::Signer, A: Activity + serde::Serialize, diff --git a/plume-models/src/follows.rs b/plume-models/src/follows.rs index 91805f25..7cca5f08 100644 --- a/plume-models/src/follows.rs +++ b/plume-models/src/follows.rs @@ -10,7 +10,7 @@ use activitystreams::{ }; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl}; use plume_common::activity_pub::{ - broadcast07, + broadcast, inbox::{AsActor, AsObject, FromId}, sign::Signer, Id, IntoId, PUBLIC_VISIBILITY, @@ -106,7 +106,7 @@ impl Follow { res.notify(conn)?; let accept = res.build_accept07(from, target, follow)?; - broadcast07( + broadcast( &*target, accept, vec![from.clone()], diff --git a/src/api/posts.rs b/src/api/posts.rs index ca76e611..2de03517 100644 --- a/src/api/posts.rs +++ b/src/api/posts.rs @@ -3,7 +3,7 @@ use rocket_contrib::json::Json; use crate::api::{authorization::*, Api, ApiError}; use plume_api::posts::*; -use plume_common::{activity_pub::broadcast07, utils::md_to_html}; +use plume_common::{activity_pub::broadcast, utils::md_to_html}; use plume_models::{ blogs::Blog, db_conn::DbConn, instance::Instance, medias::Media, mentions::*, post_authors::*, posts::*, safe_string::SafeString, tags::*, timeline::*, users::User, Error, PlumeRocket, @@ -202,7 +202,7 @@ pub fn create( let act = post.create_activity07(&conn)?; let dest = User::one_by_instance(&conn)?; - worker.execute(move || broadcast07(&author, act, dest, CONFIG.proxy().cloned())); + worker.execute(move || broadcast(&author, act, dest, CONFIG.proxy().cloned())); } Timeline::add_to_all_timelines(&conn, &post, Kind::Original)?; diff --git a/src/routes/comments.rs b/src/routes/comments.rs index f7018139..687665e6 100644 --- a/src/routes/comments.rs +++ b/src/routes/comments.rs @@ -11,7 +11,7 @@ use std::time::Duration; use crate::routes::errors::ErrorPage; use crate::template_utils::IntoContext; use plume_common::{ - activity_pub::{broadcast07, ActivityStream, ApRequest}, + activity_pub::{broadcast, ActivityStream, ApRequest}, utils, }; use plume_models::{ @@ -88,7 +88,7 @@ pub fn create( let dest = User::one_by_instance(&conn).expect("comments::create: dest error"); let user_clone = user.clone(); rockets.worker.execute(move || { - broadcast07(&user_clone, new_comment, dest, CONFIG.proxy().cloned()) + broadcast(&user_clone, new_comment, dest, CONFIG.proxy().cloned()) }); Flash::success( @@ -158,7 +158,7 @@ pub fn delete( let user_c = user.clone(); rockets.worker.execute(move || { - broadcast07(&user_c, delete_activity, dest, CONFIG.proxy().cloned()) + broadcast(&user_c, delete_activity, dest, CONFIG.proxy().cloned()) }); rockets .worker diff --git a/src/routes/instance.rs b/src/routes/instance.rs index 3864f20c..06cf63cd 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -11,7 +11,7 @@ use validator::{Validate, ValidationErrors}; use crate::inbox; use crate::routes::{errors::ErrorPage, rocket_uri_macro_static_files, Page, RespondOrRedirect}; use crate::template_utils::{IntoContext, Ructe}; -use plume_common::activity_pub::{broadcast07, inbox::FromId}; +use plume_common::activity_pub::{broadcast, inbox::FromId}; use plume_models::{ admin::*, blocklisted_emails::*, @@ -383,7 +383,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)?; - worker.execute(move || broadcast07(&u, delete_act, target, CONFIG.proxy().cloned())); + worker.execute(move || broadcast(&u, delete_act, target, CONFIG.proxy().cloned())); } Ok(()) diff --git a/src/routes/likes.rs b/src/routes/likes.rs index 6ef57225..fc1c2970 100644 --- a/src/routes/likes.rs +++ b/src/routes/likes.rs @@ -3,7 +3,7 @@ use rocket_i18n::I18n; use crate::routes::errors::ErrorPage; use crate::utils::requires_login; -use plume_common::activity_pub::broadcast07; +use plume_common::activity_pub::broadcast; use plume_models::{ blogs::Blog, db_conn::DbConn, inbox::inbox, likes, posts::Post, timeline::*, users::User, Error, PlumeRocket, CONFIG, @@ -30,7 +30,7 @@ pub fn create( let act = like.to_activity07(&*conn)?; rockets .worker - .execute(move || broadcast07(&user, act, dest, CONFIG.proxy().cloned())); + .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)?; @@ -42,7 +42,7 @@ pub fn create( let dest = User::one_by_instance(&conn)?; rockets .worker - .execute(move || broadcast07(&user, delete_act, dest, CONFIG.proxy().cloned())); + .execute(move || broadcast(&user, delete_act, dest, CONFIG.proxy().cloned())); } Ok(Redirect::to(uri!( diff --git a/src/routes/posts.rs b/src/routes/posts.rs index 61c3594c..a27d6f1d 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -16,7 +16,7 @@ use crate::routes::{ use crate::template_utils::{IntoContext, Ructe}; use crate::utils::requires_login; use plume_common::activity_pub::{ - broadcast07, ActivityStream, ApRequest, LicensedArticle as LicensedArticle07, + broadcast, ActivityStream, ApRequest, LicensedArticle as LicensedArticle07, }; use plume_common::utils::md_to_html; use plume_models::{ @@ -347,7 +347,7 @@ pub fn update( let dest = User::one_by_instance(&conn).expect("post::update: dest error"); rockets .worker - .execute(move || broadcast07(&user, act, dest, CONFIG.proxy().cloned())); + .execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned())); Timeline::add_to_all_timelines(&conn, &post, Kind::Original).ok(); } else { @@ -357,7 +357,7 @@ pub fn update( let dest = User::one_by_instance(&conn).expect("posts::update: dest error"); rockets .worker - .execute(move || broadcast07(&user, act, dest, CONFIG.proxy().cloned())); + .execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned())); } } @@ -546,7 +546,7 @@ pub fn create( .expect("posts::create: activity error"); let dest = User::one_by_instance(&conn).expect("posts::create: dest error"); let worker = &rockets.worker; - worker.execute(move || broadcast07(&user, act, dest, CONFIG.proxy().cloned())); + worker.execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned())); Timeline::add_to_all_timelines(&conn, &post, Kind::Original)?; } @@ -616,7 +616,7 @@ pub fn delete( let user_c = user.clone(); rockets .worker - .execute(move || broadcast07(&user_c, delete_activity, dest, CONFIG.proxy().cloned())); + .execute(move || broadcast(&user_c, delete_activity, dest, CONFIG.proxy().cloned())); rockets .worker .execute_after(Duration::from_secs(10 * 60), move || { diff --git a/src/routes/reshares.rs b/src/routes/reshares.rs index 2c14cf9f..e815486b 100644 --- a/src/routes/reshares.rs +++ b/src/routes/reshares.rs @@ -3,7 +3,7 @@ use rocket_i18n::I18n; use crate::routes::errors::ErrorPage; use crate::utils::requires_login; -use plume_common::activity_pub::broadcast07; +use plume_common::activity_pub::broadcast; use plume_models::{ blogs::Blog, db_conn::DbConn, inbox::inbox, posts::Post, reshares::*, timeline::*, users::User, Error, PlumeRocket, CONFIG, @@ -30,7 +30,7 @@ pub fn create( let act = reshare.to_activity07(&conn)?; rockets .worker - .execute(move || broadcast07(&user, act, dest, CONFIG.proxy().cloned())); + .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)?; @@ -42,7 +42,7 @@ pub fn create( let dest = User::one_by_instance(&conn)?; rockets .worker - .execute(move || broadcast07(&user, delete_act, dest, CONFIG.proxy().cloned())); + .execute(move || broadcast(&user, delete_act, dest, CONFIG.proxy().cloned())); } Ok(Redirect::to(uri!( diff --git a/src/routes/user.rs b/src/routes/user.rs index c8327ea7..259aaf4d 100644 --- a/src/routes/user.rs +++ b/src/routes/user.rs @@ -18,7 +18,7 @@ use crate::routes::{ }; use crate::template_utils::{IntoContext, Ructe}; use crate::utils::requires_login; -use plume_common::activity_pub::{broadcast07, ActivityStream, ApRequest, CustomPerson, Id}; +use plume_common::activity_pub::{broadcast, ActivityStream, ApRequest, CustomPerson, Id}; use plume_common::utils::md_to_html; use plume_models::{ blogs::Blog, @@ -112,7 +112,7 @@ pub fn follow( let msg = i18n!(rockets.intl.catalog, "You are no longer following {}."; target.name()); rockets .worker - .execute(move || broadcast07(&user, delete_act, vec![target], CONFIG.proxy().cloned())); + .execute(move || broadcast(&user, delete_act, vec![target], CONFIG.proxy().cloned())); msg } else { let f = follows::Follow::insert( @@ -129,7 +129,7 @@ pub fn follow( let msg = i18n!(rockets.intl.catalog, "You are now following {}."; target.name()); rockets .worker - .execute(move || broadcast07(&user, act, vec![target], CONFIG.proxy().cloned())); + .execute(move || broadcast(&user, act, vec![target], CONFIG.proxy().cloned())); msg }; Ok(Flash::success( @@ -389,7 +389,7 @@ pub fn delete( let delete_act = account.delete_activity07(&conn)?; rockets .worker - .execute(move || broadcast07(&account, delete_act, target, CONFIG.proxy().cloned())); + .execute(move || broadcast(&account, delete_act, target, CONFIG.proxy().cloned())); if let Some(cookie) = cookies.get_private(AUTH_COOKIE) { cookies.remove_private(cookie);