From: Dessalines Date: Thu, 18 Mar 2021 14:52:25 +0000 (-0400) Subject: Moving send email check inside function. X-Git-Url: http://these/git/readmes/%7Bthis.props.banner%7D?a=commitdiff_plain;h=99e5a4d1c39f25f94c623964d43dea57d3c42bbc;p=lemmy.git Moving send email check inside function. --- diff --git a/crates/api/src/local_user.rs b/crates/api/src/local_user.rs index 50cc028b..bca48ffa 100644 --- a/crates/api/src/local_user.rs +++ b/crates/api/src/local_user.rs @@ -1157,14 +1157,12 @@ impl Perform for CreatePrivateMessage { }) .await? { - if local_recipient.local_user.send_notifications_to_email { - send_email_to_user( - &local_recipient, - "Private Message from", - "Private Message", - &content_slurs_removed, - ); - } + send_email_to_user( + &local_recipient, + "Private Message from", + "Private Message", + &content_slurs_removed, + ); let local_recipient_id = local_recipient.local_user.id; context.chat_server().do_send(SendUserRoomMessage { diff --git a/crates/api_structs/src/lib.rs b/crates/api_structs/src/lib.rs index e25b0579..ea3a0556 100644 --- a/crates/api_structs/src/lib.rs +++ b/crates/api_structs/src/lib.rs @@ -101,7 +101,7 @@ fn do_send_local_notifs( PersonMention::create(&conn, &user_mention_form).ok(); // Send an email to those local users that have notifications on - if do_send_email && mention_user_view.local_user.send_notifications_to_email { + if do_send_email { send_email_to_user( &mention_user_view, "Mentioned by", @@ -121,7 +121,7 @@ fn do_send_local_notifs( { recipient_ids.push(parent_user_view.local_user.id); - if do_send_email && parent_user_view.local_user.send_notifications_to_email { + if do_send_email { send_email_to_user( &parent_user_view, "Reply from", @@ -139,7 +139,7 @@ fn do_send_local_notifs( if let Ok(parent_user_view) = LocalUserView::read_person(&conn, post.creator_id) { recipient_ids.push(parent_user_view.local_user.id); - if do_send_email && parent_user_view.local_user.send_notifications_to_email { + if do_send_email { send_email_to_user( &parent_user_view, "Reply from", @@ -160,7 +160,7 @@ pub fn send_email_to_user( body_text: &str, comment_content: &str, ) { - if local_user_view.person.banned { + if local_user_view.person.banned || !local_user_view.local_user.send_notifications_to_email { return; }