Rename: broadcast07() -> broadcast()

This commit is contained in:
Kitaiti Makoto 2022-05-03 01:12:39 +09:00
parent 5c59687cb8
commit 1dd176dd80
9 changed files with 25 additions and 25 deletions

View File

@ -120,7 +120,7 @@ impl<'a, 'r> FromRequest<'a, 'r> for ApRequest {
} }
} }
pub fn broadcast07<S, T, A, C>(sender: &S, act: A, to: Vec<T>, proxy: Option<reqwest::Proxy>) pub fn broadcast<S, T, A, C>(sender: &S, act: A, to: Vec<T>, proxy: Option<reqwest::Proxy>)
where where
S: sign::Signer, S: sign::Signer,
A: Activity + serde::Serialize, A: Activity + serde::Serialize,

View File

@ -10,7 +10,7 @@ use activitystreams::{
}; };
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl};
use plume_common::activity_pub::{ use plume_common::activity_pub::{
broadcast07, broadcast,
inbox::{AsActor, AsObject, FromId}, inbox::{AsActor, AsObject, FromId},
sign::Signer, sign::Signer,
Id, IntoId, PUBLIC_VISIBILITY, Id, IntoId, PUBLIC_VISIBILITY,
@ -106,7 +106,7 @@ impl Follow {
res.notify(conn)?; res.notify(conn)?;
let accept = res.build_accept07(from, target, follow)?; let accept = res.build_accept07(from, target, follow)?;
broadcast07( broadcast(
&*target, &*target,
accept, accept,
vec![from.clone()], vec![from.clone()],

View File

@ -3,7 +3,7 @@ use rocket_contrib::json::Json;
use crate::api::{authorization::*, Api, ApiError}; use crate::api::{authorization::*, Api, ApiError};
use plume_api::posts::*; 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::{ use plume_models::{
blogs::Blog, db_conn::DbConn, instance::Instance, medias::Media, mentions::*, post_authors::*, blogs::Blog, db_conn::DbConn, instance::Instance, medias::Media, mentions::*, post_authors::*,
posts::*, safe_string::SafeString, tags::*, timeline::*, users::User, Error, PlumeRocket, posts::*, safe_string::SafeString, tags::*, timeline::*, users::User, Error, PlumeRocket,
@ -202,7 +202,7 @@ pub fn create(
let act = post.create_activity07(&conn)?; let act = post.create_activity07(&conn)?;
let dest = User::one_by_instance(&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)?; Timeline::add_to_all_timelines(&conn, &post, Kind::Original)?;

View File

@ -11,7 +11,7 @@ use std::time::Duration;
use crate::routes::errors::ErrorPage; use crate::routes::errors::ErrorPage;
use crate::template_utils::IntoContext; use crate::template_utils::IntoContext;
use plume_common::{ use plume_common::{
activity_pub::{broadcast07, ActivityStream, ApRequest}, activity_pub::{broadcast, ActivityStream, ApRequest},
utils, utils,
}; };
use plume_models::{ use plume_models::{
@ -88,7 +88,7 @@ pub fn create(
let dest = User::one_by_instance(&conn).expect("comments::create: dest error"); let dest = User::one_by_instance(&conn).expect("comments::create: dest error");
let user_clone = user.clone(); let user_clone = user.clone();
rockets.worker.execute(move || { rockets.worker.execute(move || {
broadcast07(&user_clone, new_comment, dest, CONFIG.proxy().cloned()) broadcast(&user_clone, new_comment, dest, CONFIG.proxy().cloned())
}); });
Flash::success( Flash::success(
@ -158,7 +158,7 @@ pub fn delete(
let user_c = user.clone(); let user_c = user.clone();
rockets.worker.execute(move || { rockets.worker.execute(move || {
broadcast07(&user_c, delete_activity, dest, CONFIG.proxy().cloned()) broadcast(&user_c, delete_activity, dest, CONFIG.proxy().cloned())
}); });
rockets rockets
.worker .worker

View File

@ -11,7 +11,7 @@ use validator::{Validate, ValidationErrors};
use crate::inbox; use crate::inbox;
use crate::routes::{errors::ErrorPage, rocket_uri_macro_static_files, Page, RespondOrRedirect}; use crate::routes::{errors::ErrorPage, rocket_uri_macro_static_files, Page, RespondOrRedirect};
use crate::template_utils::{IntoContext, Ructe}; 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::{ use plume_models::{
admin::*, admin::*,
blocklisted_emails::*, blocklisted_emails::*,
@ -383,7 +383,7 @@ fn ban(id: i32, conn: &Connection, worker: &ScheduledThreadPool) -> Result<(), E
.unwrap(); .unwrap();
let target = User::one_by_instance(&*conn)?; let target = User::one_by_instance(&*conn)?;
let delete_act = u.delete_activity07(&*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(()) Ok(())

View File

@ -3,7 +3,7 @@ use rocket_i18n::I18n;
use crate::routes::errors::ErrorPage; use crate::routes::errors::ErrorPage;
use crate::utils::requires_login; use crate::utils::requires_login;
use plume_common::activity_pub::broadcast07; use plume_common::activity_pub::broadcast;
use plume_models::{ use plume_models::{
blogs::Blog, db_conn::DbConn, inbox::inbox, likes, posts::Post, timeline::*, users::User, blogs::Blog, db_conn::DbConn, inbox::inbox, likes, posts::Post, timeline::*, users::User,
Error, PlumeRocket, CONFIG, Error, PlumeRocket, CONFIG,
@ -30,7 +30,7 @@ pub fn create(
let act = like.to_activity07(&*conn)?; let act = like.to_activity07(&*conn)?;
rockets rockets
.worker .worker
.execute(move || broadcast07(&user, act, dest, CONFIG.proxy().cloned())); .execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned()));
} else { } else {
let like = likes::Like::find_by_user_on_post(&conn, user.id, post.id)?; 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_undo07(&conn)?;
@ -42,7 +42,7 @@ pub fn create(
let dest = User::one_by_instance(&conn)?; let dest = User::one_by_instance(&conn)?;
rockets rockets
.worker .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!( Ok(Redirect::to(uri!(

View File

@ -16,7 +16,7 @@ use crate::routes::{
use crate::template_utils::{IntoContext, Ructe}; use crate::template_utils::{IntoContext, Ructe};
use crate::utils::requires_login; use crate::utils::requires_login;
use plume_common::activity_pub::{ 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_common::utils::md_to_html;
use plume_models::{ use plume_models::{
@ -347,7 +347,7 @@ pub fn update(
let dest = User::one_by_instance(&conn).expect("post::update: dest error"); let dest = User::one_by_instance(&conn).expect("post::update: dest error");
rockets rockets
.worker .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(); Timeline::add_to_all_timelines(&conn, &post, Kind::Original).ok();
} else { } else {
@ -357,7 +357,7 @@ pub fn update(
let dest = User::one_by_instance(&conn).expect("posts::update: dest error"); let dest = User::one_by_instance(&conn).expect("posts::update: dest error");
rockets rockets
.worker .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"); .expect("posts::create: activity error");
let dest = User::one_by_instance(&conn).expect("posts::create: dest error"); let dest = User::one_by_instance(&conn).expect("posts::create: dest error");
let worker = &rockets.worker; 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)?; Timeline::add_to_all_timelines(&conn, &post, Kind::Original)?;
} }
@ -616,7 +616,7 @@ pub fn delete(
let user_c = user.clone(); let user_c = user.clone();
rockets rockets
.worker .worker
.execute(move || broadcast07(&user_c, delete_activity, dest, CONFIG.proxy().cloned())); .execute(move || broadcast(&user_c, delete_activity, dest, CONFIG.proxy().cloned()));
rockets rockets
.worker .worker
.execute_after(Duration::from_secs(10 * 60), move || { .execute_after(Duration::from_secs(10 * 60), move || {

View File

@ -3,7 +3,7 @@ use rocket_i18n::I18n;
use crate::routes::errors::ErrorPage; use crate::routes::errors::ErrorPage;
use crate::utils::requires_login; use crate::utils::requires_login;
use plume_common::activity_pub::broadcast07; use plume_common::activity_pub::broadcast;
use plume_models::{ use plume_models::{
blogs::Blog, db_conn::DbConn, inbox::inbox, posts::Post, reshares::*, timeline::*, users::User, blogs::Blog, db_conn::DbConn, inbox::inbox, posts::Post, reshares::*, timeline::*, users::User,
Error, PlumeRocket, CONFIG, Error, PlumeRocket, CONFIG,
@ -30,7 +30,7 @@ pub fn create(
let act = reshare.to_activity07(&conn)?; let act = reshare.to_activity07(&conn)?;
rockets rockets
.worker .worker
.execute(move || broadcast07(&user, act, dest, CONFIG.proxy().cloned())); .execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned()));
} else { } else {
let reshare = Reshare::find_by_user_on_post(&conn, user.id, post.id)?; 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_undo07(&conn)?;
@ -42,7 +42,7 @@ pub fn create(
let dest = User::one_by_instance(&conn)?; let dest = User::one_by_instance(&conn)?;
rockets rockets
.worker .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!( Ok(Redirect::to(uri!(

View File

@ -18,7 +18,7 @@ use crate::routes::{
}; };
use crate::template_utils::{IntoContext, Ructe}; use crate::template_utils::{IntoContext, Ructe};
use crate::utils::requires_login; 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_common::utils::md_to_html;
use plume_models::{ use plume_models::{
blogs::Blog, blogs::Blog,
@ -112,7 +112,7 @@ pub fn follow(
let msg = i18n!(rockets.intl.catalog, "You are no longer following {}."; target.name()); let msg = i18n!(rockets.intl.catalog, "You are no longer following {}."; target.name());
rockets rockets
.worker .worker
.execute(move || broadcast07(&user, delete_act, vec![target], CONFIG.proxy().cloned())); .execute(move || broadcast(&user, delete_act, vec![target], CONFIG.proxy().cloned()));
msg msg
} else { } else {
let f = follows::Follow::insert( let f = follows::Follow::insert(
@ -129,7 +129,7 @@ pub fn follow(
let msg = i18n!(rockets.intl.catalog, "You are now following {}."; target.name()); let msg = i18n!(rockets.intl.catalog, "You are now following {}."; target.name());
rockets rockets
.worker .worker
.execute(move || broadcast07(&user, act, vec![target], CONFIG.proxy().cloned())); .execute(move || broadcast(&user, act, vec![target], CONFIG.proxy().cloned()));
msg msg
}; };
Ok(Flash::success( Ok(Flash::success(
@ -389,7 +389,7 @@ pub fn delete(
let delete_act = account.delete_activity07(&conn)?; let delete_act = account.delete_activity07(&conn)?;
rockets rockets
.worker .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) { if let Some(cookie) = cookies.get_private(AUTH_COOKIE) {
cookies.remove_private(cookie); cookies.remove_private(cookie);