remove Searcher from Post::update()
thereby decoupling the two systems (for updates, anyway) That means, consumers of Post need to update_document themselves! Post (in update) now only talks to the database) Tests for this will now be failing, as they haven't been touched yet
This commit is contained in:
parent
06e20299e0
commit
d7e380f83e
1 changed files with 8 additions and 6 deletions
|
@ -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, Result, CONFIG,
|
||||
safe_string::SafeString, schema::posts, search::Searcher, search::UpdateDocument, tags::*,
|
||||
timeline::*, users::User, Connection, Error, PlumeRocket, Result, CONFIG,
|
||||
};
|
||||
use activitypub::{
|
||||
activity::{Create, Delete, Update},
|
||||
|
@ -19,6 +19,8 @@ use plume_common::{
|
|||
},
|
||||
utils::md_to_html,
|
||||
};
|
||||
|
||||
use riker::actors::*;
|
||||
use serde_json;
|
||||
use std::collections::HashSet;
|
||||
|
||||
|
@ -82,10 +84,9 @@ impl Post {
|
|||
Ok(post)
|
||||
}
|
||||
|
||||
pub fn update(&self, conn: &Connection, searcher: &Searcher) -> Result<Self> {
|
||||
pub fn update(&self, conn: &Connection) -> Result<Self> {
|
||||
diesel::update(self).set(self).execute(conn)?;
|
||||
let post = Self::get(conn, self.id)?;
|
||||
searcher.update_document(&post)?;
|
||||
Ok(post)
|
||||
}
|
||||
|
||||
|
@ -728,7 +729,7 @@ impl AsObject<User, Update, &PlumeRocket> for PostUpdate {
|
|||
|
||||
fn activity(self, c: &PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
let conn = &*c.conn;
|
||||
let searcher = &c.searcher;
|
||||
let searcher_actor = &c.actors.select("searcher-actor").unwrap();
|
||||
let mut post = Post::from_id(c, &self.ap_url, None).map_err(|(_, e)| e)?;
|
||||
|
||||
if !post.is_author(conn, actor.id)? {
|
||||
|
@ -791,7 +792,8 @@ impl AsObject<User, Update, &PlumeRocket> for PostUpdate {
|
|||
post.update_hashtags(conn, hashtags)?;
|
||||
}
|
||||
|
||||
post.update(conn, searcher)?;
|
||||
post.update(conn)?;
|
||||
searcher_actor.try_tell(UpdateDocument(post.clone()), None);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue