Remove searcher from arguments of Post::delete() and dependented methods
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
ap_url, instance::*, medias::Media, posts::Post, safe_string::SafeString, schema::blogs,
|
||||
search::Searcher, users::User, Connection, Error, PlumeRocket, Result, CONFIG, ITEMS_PER_PAGE,
|
||||
users::User, Connection, Error, PlumeRocket, Result, CONFIG, ITEMS_PER_PAGE,
|
||||
};
|
||||
use activitypub::{
|
||||
actor::Group,
|
||||
@@ -317,9 +317,9 @@ impl Blog {
|
||||
.and_then(|c| c.url().ok())
|
||||
}
|
||||
|
||||
pub fn delete(&self, conn: &Connection, searcher: &Searcher) -> Result<()> {
|
||||
pub fn delete(&self, conn: &Connection) -> Result<()> {
|
||||
for post in Post::get_for_blog(conn, &self)? {
|
||||
post.delete(conn, searcher)?;
|
||||
post.delete(conn)?;
|
||||
}
|
||||
diesel::delete(self)
|
||||
.execute(conn)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
ap_url, blogs::Blog, instance::Instance, medias::Media, mentions::Mention, post_authors::*,
|
||||
safe_string::SafeString, schema::posts, search::Searcher, tags::*, timeline::*, users::User,
|
||||
Connection, Error, PlumeRocket, PostEvent::*, Result, CONFIG, POST_CHAN,
|
||||
safe_string::SafeString, schema::posts, tags::*, timeline::*, users::User, Connection, Error,
|
||||
PlumeRocket, PostEvent::*, Result, CONFIG, POST_CHAN,
|
||||
};
|
||||
use activitypub::{
|
||||
activity::{Create, Delete, Update},
|
||||
@@ -93,7 +93,7 @@ impl Post {
|
||||
Ok(post)
|
||||
}
|
||||
|
||||
pub fn delete(&self, conn: &Connection, _searcher: &Searcher) -> Result<()> {
|
||||
pub fn delete(&self, conn: &Connection) -> Result<()> {
|
||||
for m in Mention::list_for_post(&conn, self.id)? {
|
||||
m.delete(conn)?;
|
||||
}
|
||||
@@ -703,7 +703,7 @@ impl AsObject<User, Delete, &PlumeRocket> for Post {
|
||||
.into_iter()
|
||||
.any(|a| actor.id == a.id);
|
||||
if can_delete {
|
||||
self.delete(&c.conn, &c.searcher).map(|_| ())
|
||||
self.delete(&c.conn).map(|_| ())
|
||||
} else {
|
||||
Err(Error::Unauthorized)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::{
|
||||
ap_url, blocklisted_emails::BlocklistedEmail, blogs::Blog, db_conn::DbConn, follows::Follow,
|
||||
instance::*, medias::Media, notifications::Notification, post_authors::PostAuthor, posts::Post,
|
||||
safe_string::SafeString, schema::users, search::Searcher, timeline::Timeline, Connection,
|
||||
Error, PlumeRocket, Result, CONFIG, ITEMS_PER_PAGE,
|
||||
safe_string::SafeString, schema::users, timeline::Timeline, Connection, Error, PlumeRocket,
|
||||
Result, CONFIG, ITEMS_PER_PAGE,
|
||||
};
|
||||
use activitypub::{
|
||||
activity::Delete,
|
||||
@@ -129,14 +129,14 @@ impl User {
|
||||
.map_err(Error::from)
|
||||
}
|
||||
|
||||
pub fn delete(&self, conn: &Connection, searcher: &Searcher) -> Result<()> {
|
||||
pub fn delete(&self, conn: &Connection) -> Result<()> {
|
||||
use crate::schema::post_authors;
|
||||
|
||||
for blog in Blog::find_for_author(conn, self)?
|
||||
.iter()
|
||||
.filter(|b| b.count_authors(conn).map(|c| c <= 1).unwrap_or(false))
|
||||
{
|
||||
blog.delete(conn, searcher)?;
|
||||
blog.delete(conn)?;
|
||||
}
|
||||
// delete the posts if they is the only author
|
||||
let all_their_posts_ids: Vec<i32> = post_authors::table
|
||||
@@ -156,7 +156,7 @@ impl User {
|
||||
.unwrap_or(&0)
|
||||
> &0;
|
||||
if !has_other_authors {
|
||||
Post::get(conn, post_id)?.delete(conn, searcher)?;
|
||||
Post::get(conn, post_id)?.delete(conn)?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1037,7 +1037,7 @@ impl AsObject<User, Delete, &PlumeRocket> for User {
|
||||
|
||||
fn activity(self, c: &PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
if self.id == actor.id {
|
||||
self.delete(&c.conn, &c.searcher).map(|_| ())
|
||||
self.delete(&c.conn).map(|_| ())
|
||||
} else {
|
||||
Err(Error::Unauthorized)
|
||||
}
|
||||
@@ -1227,9 +1227,7 @@ pub(crate) mod tests {
|
||||
let inserted = fill_database(conn);
|
||||
|
||||
assert!(User::get(conn, inserted[0].id).is_ok());
|
||||
inserted[0]
|
||||
.delete(conn, &get_searcher(&CONFIG.search_tokenizers))
|
||||
.unwrap();
|
||||
inserted[0].delete(conn).unwrap();
|
||||
assert!(User::get(conn, inserted[0].id).is_err());
|
||||
Ok(())
|
||||
});
|
||||
@@ -1319,7 +1317,7 @@ pub(crate) mod tests {
|
||||
let users = fill_database(conn);
|
||||
|
||||
let ap_repr = users[0].to_activity(conn).unwrap();
|
||||
users[0].delete(conn, &*r.searcher).unwrap();
|
||||
users[0].delete(conn).unwrap();
|
||||
let user = User::from_activity(&r, ap_repr).unwrap();
|
||||
|
||||
assert_eq!(user.username, users[0].username);
|
||||
|
||||
Reference in New Issue
Block a user