mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-26 13:31:02 +00:00
Send event to channel when post updated
This commit is contained in:
parent
69963689f9
commit
aae2073146
1 changed files with 13 additions and 2 deletions
|
@ -85,10 +85,11 @@ impl Post {
|
|||
Ok(post)
|
||||
}
|
||||
|
||||
pub fn update(&self, conn: &Connection, searcher: &Searcher) -> Result<Self> {
|
||||
pub fn update(&self, conn: &Connection, _searcher: &Searcher) -> Result<Self> {
|
||||
diesel::update(self).set(self).execute(conn)?;
|
||||
let post = Self::get(conn, self.id)?;
|
||||
searcher.update_document(conn, &post)?;
|
||||
// TODO: Call publish_published() when newly published
|
||||
self.publish_updated();
|
||||
Ok(post)
|
||||
}
|
||||
|
||||
|
@ -559,6 +560,16 @@ impl Post {
|
|||
None,
|
||||
)
|
||||
}
|
||||
|
||||
fn publish_updated(&self) {
|
||||
POST_CHAN.tell(
|
||||
Publish {
|
||||
msg: PostUpdated(self.clone()),
|
||||
topic: "post.updated".into(),
|
||||
},
|
||||
None,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromId<PlumeRocket> for Post {
|
||||
|
|
Loading…
Reference in a new issue