From c6c74ab1e3f44b6cb74ca9a3dac150458746616f Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 5 Nov 2020 16:13:01 +0100 Subject: [PATCH] Also check for ban when sending private message notification --- lemmy_api/src/user.rs | 26 +++++++------------------- lemmy_structs/src/lib.rs | 2 +- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/lemmy_api/src/user.rs b/lemmy_api/src/user.rs index ad3d9808..6dffc1a7 100644 --- a/lemmy_api/src/user.rs +++ b/lemmy_api/src/user.rs @@ -38,7 +38,7 @@ use lemmy_db::{ ListingType, SortType, }; -use lemmy_structs::{blocking, user::*}; +use lemmy_structs::{blocking, send_email_to_user, user::*}; use lemmy_utils::{ apub::{generate_actor_keypair, make_apub_endpoint, EndpointType}, email::send_email, @@ -61,7 +61,6 @@ use lemmy_websocket::{ LemmyContext, UserOperation, }; -use log::error; use std::str::FromStr; #[async_trait::async_trait(?Send)] @@ -1041,23 +1040,12 @@ impl Perform for CreatePrivateMessage { let recipient_user = blocking(context.pool(), move |conn| User_::read(conn, recipient_id)).await??; if recipient_user.send_notifications_to_email { - if let Some(email) = recipient_user.email { - let subject = &format!( - "{} - Private Message from {}", - Settings::get().hostname, - user.name, - ); - let html = &format!( - "

Private Message


{} - {}

inbox", - user.name, - &content_slurs_removed, - Settings::get().get_protocol_and_hostname() - ); - match send_email(subject, &email, &recipient_user.name, html) { - Ok(_o) => _o, - Err(e) => error!("{}", e), - }; - } + send_email_to_user( + recipient_user, + "Private Message from", + "Private Message", + &content_slurs_removed, + ); } let message = blocking(context.pool(), move |conn| { diff --git a/lemmy_structs/src/lib.rs b/lemmy_structs/src/lib.rs index 070cebfb..5d2e4273 100644 --- a/lemmy_structs/src/lib.rs +++ b/lemmy_structs/src/lib.rs @@ -146,7 +146,7 @@ fn do_send_local_notifs( recipient_ids } -fn send_email_to_user(user: User_, subject_text: &str, body_text: &str, comment_content: &str) { +pub fn send_email_to_user(user: User_, subject_text: &str, body_text: &str, comment_content: &str) { if user.banned { return; } -- 2.44.1