From: Dessalines Date: Wed, 15 May 2019 16:46:39 +0000 (-0700) Subject: Enforce -1 or 1 like scores X-Git-Url: http://these/git/%7B%60%24%7BghostArchiveUrl%7D/static/%24%7BappleTouchIcon%7D?a=commitdiff_plain;h=b1490ef51a99004c72247157ae6501ffa3e4e99d;p=lemmy.git Enforce -1 or 1 like scores --- diff --git a/server/src/api/comment.rs b/server/src/api/comment.rs index 65516aca..ffd7da2e 100644 --- a/server/src/api/comment.rs +++ b/server/src/api/comment.rs @@ -294,7 +294,8 @@ impl Perform for Oper { CommentLike::remove(&conn, &like_form)?; // Only add the like if the score isnt 0 - if &like_form.score != &0 { + let do_add = &like_form.score != &0 && (&like_form.score == &1 || &like_form.score == &-1); + if do_add { let _inserted_like = match CommentLike::like(&conn, &like_form) { Ok(like) => like, Err(_e) => { diff --git a/server/src/api/post.rs b/server/src/api/post.rs index 39df9546..a6010781 100644 --- a/server/src/api/post.rs +++ b/server/src/api/post.rs @@ -297,7 +297,8 @@ impl Perform for Oper { PostLike::remove(&conn, &like_form)?; // Only add the like if the score isnt 0 - if &like_form.score != &0 { + let do_add = &like_form.score != &0 && (&like_form.score == &1 || &like_form.score == &-1); + if do_add { let _inserted_like = match PostLike::like(&conn, &like_form) { Ok(like) => like, Err(_e) => {