mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-26 22:40:21 +00:00
Enforce -1 or 1 like scores
This commit is contained in:
parent
8820eac129
commit
b1490ef51a
2 changed files with 4 additions and 2 deletions
|
@ -294,7 +294,8 @@ impl Perform<CommentResponse> for Oper<CreateCommentLike> {
|
||||||
CommentLike::remove(&conn, &like_form)?;
|
CommentLike::remove(&conn, &like_form)?;
|
||||||
|
|
||||||
// Only add the like if the score isnt 0
|
// 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) {
|
let _inserted_like = match CommentLike::like(&conn, &like_form) {
|
||||||
Ok(like) => like,
|
Ok(like) => like,
|
||||||
Err(_e) => {
|
Err(_e) => {
|
||||||
|
|
|
@ -297,7 +297,8 @@ impl Perform<CreatePostLikeResponse> for Oper<CreatePostLike> {
|
||||||
PostLike::remove(&conn, &like_form)?;
|
PostLike::remove(&conn, &like_form)?;
|
||||||
|
|
||||||
// Only add the like if the score isnt 0
|
// 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) {
|
let _inserted_like = match PostLike::like(&conn, &like_form) {
|
||||||
Ok(like) => like,
|
Ok(like) => like,
|
||||||
Err(_e) => {
|
Err(_e) => {
|
||||||
|
|
Loading…
Reference in a new issue