Browse Source

use searcher_actor for posts update route (instead of post.update())

pull/813/head
Mina Galić 3 months ago
parent
commit
06e20299e0
Signed by: igalic <me+github@igalic.co> GPG Key ID: ACFEFF7F6A123A86
2 changed files with 6 additions and 3 deletions
  1. +1
    -1
      plume-models/src/search/searcher.rs
  2. +5
    -2
      src/routes/posts.rs

+ 1
- 1
plume-models/src/search/searcher.rs View File

@@ -33,7 +33,7 @@ pub struct Searcher {
pub struct AddDocument(Post);

#[derive(Clone, Debug)]
pub struct UpdateDocument(Post);
pub struct UpdateDocument(pub Post);

#[derive(Clone, Debug)]
pub struct DeleteDocument(Post);


+ 5
- 2
src/routes/posts.rs View File

@@ -1,5 +1,6 @@
use chrono::Utc;
use heck::{CamelCase, KebabCase};
use riker::actors::*;
use rocket::request::LenientForm;
use rocket::response::{Flash, Redirect};
use rocket_i18n::I18n;
@@ -26,6 +27,7 @@ use plume_models::{
post_authors::*,
posts::*,
safe_string::SafeString,
search::UpdateDocument,
tags::*,
timeline::*,
users::User,
@@ -297,8 +299,6 @@ pub fn update(
post.source = form.content.clone();
post.license = form.license.clone();
post.cover_id = form.cover;
post.update(&*conn, &rockets.searcher)
.expect("post::update: update error");

if post.published {
post.update_mentions(
@@ -351,6 +351,9 @@ pub fn update(
}
}

let searcher_actor = rockets.actors.select("searcher-actor").unwrap();
searcher_actor.try_tell(UpdateDocument(post.clone()), None);

Flash::success(
Redirect::to(uri!(details: blog = blog, slug = new_slug, responding_to = _)),
i18n!(intl, "Your article has been updated."),


Loading…
Cancel
Save