Remove searcher from arguments of Post::delete() and dependented methods

This commit is contained in:
Kitaiti Makoto
2021-01-07 22:51:46 +09:00
parent 2a8cc5f3ba
commit fc8ee1c3bc
7 changed files with 21 additions and 31 deletions
+1 -1
View File
@@ -230,7 +230,7 @@ pub fn delete(auth: Authorization<Write, Post>, rockets: PlumeRocket, id: i32) -
let author = User::get(&*rockets.conn, auth.0.user_id)?;
if let Ok(post) = Post::get(&*rockets.conn, id) {
if post.is_author(&*rockets.conn, author.id).unwrap_or(false) {
post.delete(&*rockets.conn, &rockets.searcher)?;
post.delete(&*rockets.conn)?;
}
}
Ok(Json(()))
+1 -2
View File
@@ -153,8 +153,7 @@ pub fn delete(name: String, rockets: PlumeRocket) -> RespondOrRedirect {
.and_then(|u| u.is_author_in(&*conn, &blog).ok())
.unwrap_or(false)
{
blog.delete(&conn, &rockets.searcher)
.expect("blog::expect: deletion error");
blog.delete(&conn).expect("blog::expect: deletion error");
Flash::success(
Redirect::to(uri!(super::instance::index)),
i18n!(rockets.intl.catalog, "Your blog was deleted."),
+3 -10
View File
@@ -21,7 +21,6 @@ use plume_models::{
instance::*,
posts::Post,
safe_string::SafeString,
search::Searcher,
timeline::Timeline,
users::{Role, User},
Connection, Error, PlumeRocket, CONFIG,
@@ -331,7 +330,6 @@ pub fn edit_users(
}
let conn = &rockets.conn;
let searcher = &*rockets.searcher;
let worker = &*rockets.worker;
match form.action {
UserActions::Admin => {
@@ -351,7 +349,7 @@ pub fn edit_users(
}
UserActions::Ban => {
for u in form.ids.clone() {
ban(u, conn, searcher, worker)?;
ban(u, conn, worker)?;
}
}
}
@@ -362,14 +360,9 @@ pub fn edit_users(
))
}
fn ban(
id: i32,
conn: &Connection,
searcher: &Searcher,
worker: &ScheduledThreadPool,
) -> Result<(), ErrorPage> {
fn ban(id: i32, conn: &Connection, worker: &ScheduledThreadPool) -> Result<(), ErrorPage> {
let u = User::get(&*conn, id)?;
u.delete(&*conn, searcher)?;
u.delete(&*conn)?;
if Instance::get_local()
.map(|i| u.instance_id == i.id)
.unwrap_or(false)
+1 -1
View File
@@ -421,7 +421,7 @@ pub fn delete(
) -> Result<Flash<Redirect>, ErrorPage> {
let account = User::find_by_fqn(&rockets, &name)?;
if user.id == account.id {
account.delete(&*rockets.conn, &rockets.searcher)?;
account.delete(&*rockets.conn)?;
let target = User::one_by_instance(&*rockets.conn)?;
let delete_act = account.delete_activity(&*rockets.conn)?;