Also check for ban when sending private message notification
This commit is contained in:
parent
d2bea09a60
commit
c6c74ab1e3
2 changed files with 8 additions and 20 deletions
|
@ -38,7 +38,7 @@ use lemmy_db::{
|
||||||
ListingType,
|
ListingType,
|
||||||
SortType,
|
SortType,
|
||||||
};
|
};
|
||||||
use lemmy_structs::{blocking, user::*};
|
use lemmy_structs::{blocking, send_email_to_user, user::*};
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
apub::{generate_actor_keypair, make_apub_endpoint, EndpointType},
|
apub::{generate_actor_keypair, make_apub_endpoint, EndpointType},
|
||||||
email::send_email,
|
email::send_email,
|
||||||
|
@ -61,7 +61,6 @@ use lemmy_websocket::{
|
||||||
LemmyContext,
|
LemmyContext,
|
||||||
UserOperation,
|
UserOperation,
|
||||||
};
|
};
|
||||||
use log::error;
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[async_trait::async_trait(?Send)]
|
#[async_trait::async_trait(?Send)]
|
||||||
|
@ -1041,23 +1040,12 @@ impl Perform for CreatePrivateMessage {
|
||||||
let recipient_user =
|
let recipient_user =
|
||||||
blocking(context.pool(), move |conn| User_::read(conn, recipient_id)).await??;
|
blocking(context.pool(), move |conn| User_::read(conn, recipient_id)).await??;
|
||||||
if recipient_user.send_notifications_to_email {
|
if recipient_user.send_notifications_to_email {
|
||||||
if let Some(email) = recipient_user.email {
|
send_email_to_user(
|
||||||
let subject = &format!(
|
recipient_user,
|
||||||
"{} - Private Message from {}",
|
"Private Message from",
|
||||||
Settings::get().hostname,
|
"Private Message",
|
||||||
user.name,
|
&content_slurs_removed,
|
||||||
);
|
);
|
||||||
let html = &format!(
|
|
||||||
"<h1>Private Message</h1><br><div>{} - {}</div><br><a href={}/inbox>inbox</a>",
|
|
||||||
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),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let message = blocking(context.pool(), move |conn| {
|
let message = blocking(context.pool(), move |conn| {
|
||||||
|
|
|
@ -146,7 +146,7 @@ fn do_send_local_notifs(
|
||||||
recipient_ids
|
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 {
|
if user.banned {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue