feat: notify: link to new comment

This commit is contained in:
Pascal Engélibert 2022-12-04 14:51:18 +01:00
commit 17e61b8a67
Signed by: tuxmain
GPG key ID: 3504BC6D362F7DCA
5 changed files with 48 additions and 9 deletions

View file

@ -1,6 +1,8 @@
#![allow(clippy::too_many_arguments)]
use crate::{config::*, db::*, helpers, locales::*, queries::*, templates::*};
use crate::{
config::*, db::*, helpers, locales::*, notify::Notification, queries::*, templates::*,
};
use argon2::{Argon2, PasswordHash, PasswordVerifier};
use crossbeam_channel::Sender;
@ -247,7 +249,7 @@ async fn handle_post_comments(
templates: &Templates,
dbs: Dbs,
locales: &Locales,
notify_send: Sender<()>,
notify_send: Sender<Notification>,
) -> tide::Result<tide::Response> {
let admin = req.cookie("admin").map_or(false, |psw| {
check_admin_password_hash(config, &String::from(psw.value()))
@ -339,7 +341,11 @@ async fn handle_post_comments(
helpers::new_pending_comment(&comment, &dbs)
.map_err(|e| error!("Adding pending comment: {:?}", e))
.ok();
notify_send.send(()).ok();
notify_send
.send(Notification {
topic: topic.to_string(),
})
.ok();
} else {
context.insert("new_comment_author", &query.comment.author);
context.insert("new_comment_email", &query.comment.email);