Don't send email notification for self replies.

- Fixes #401
pull/406/head
Dessalines 2020-01-03 13:12:19 -05:00
parent 4157bf9a02
commit 02cf67de4a
1 changed files with 36 additions and 32 deletions

View File

@ -137,6 +137,7 @@ impl Perform<CommentResponse> for Oper<CreateComment> {
match data.parent_id { match data.parent_id {
Some(parent_id) => { Some(parent_id) => {
let parent_comment = Comment::read(&conn, parent_id)?; let parent_comment = Comment::read(&conn, parent_id)?;
if parent_comment.creator_id != user_id {
let parent_user = User_::read(&conn, parent_comment.creator_id)?; let parent_user = User_::read(&conn, parent_comment.creator_id)?;
if parent_user.send_notifications_to_email { if parent_user.send_notifications_to_email {
if let Some(comment_reply_email) = parent_user.email { if let Some(comment_reply_email) = parent_user.email {
@ -156,8 +157,10 @@ impl Perform<CommentResponse> for Oper<CreateComment> {
} }
} }
} }
}
// Its a post // Its a post
None => { None => {
if post.creator_id != user_id {
let parent_user = User_::read(&conn, post.creator_id)?; let parent_user = User_::read(&conn, post.creator_id)?;
if parent_user.send_notifications_to_email { if parent_user.send_notifications_to_email {
if let Some(post_reply_email) = parent_user.email { if let Some(post_reply_email) = parent_user.email {
@ -177,6 +180,7 @@ impl Perform<CommentResponse> for Oper<CreateComment> {
} }
} }
} }
}
}; };
// You like your own comment by default // You like your own comment by default