creator_banned_from_community,
subscribed,
saved,
- my_vote,
+ comment_like,
) = comment::table
.find(comment_id)
.inner_join(user_::table)
))
.first::<CommentViewTuple>(conn)?;
+ // If a user is given, then my_vote, if None, should be 0, not null
+ // Necessary to differentiate between other user's votes
+ let my_vote = if my_user_id.is_some() && comment_like.is_none() {
+ Some(0)
+ } else {
+ comment_like
+ };
+
Ok(CommentView {
comment,
recipient,
follower,
saved,
read,
- my_vote,
+ post_like,
) = post::table
.find(post_id)
.inner_join(user_::table)
))
.first::<PostViewTuple>(conn)?;
+ // If a user is given, then my_vote, if None, should be 0, not null
+ // Necessary to differentiate between other user's votes
+ let my_vote = if my_user_id.is_some() && post_like.is_none() {
+ Some(0)
+ } else {
+ post_like
+ };
+
Ok(PostView {
post,
creator,