mirror of https://github.com/LemmyNet/lemmy.git
* Make sure my_vote is consistently missing if not voted. Fixes #3197 * Fix clippy. * Fix tests.dont_send_karma
parent
6235ff45b5
commit
5bfa4e9358
|
@ -47,6 +47,7 @@ pub struct GetPost {
|
||||||
pub comment_id: Option<CommentId>,
|
pub comment_id: Option<CommentId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[skip_serializing_none]
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
#[cfg_attr(feature = "full", derive(TS))]
|
#[cfg_attr(feature = "full", derive(TS))]
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
#[cfg_attr(feature = "full", ts(export))]
|
||||||
|
|
|
@ -542,16 +542,10 @@ impl PostView {
|
||||||
my_person_id: Option<PersonId>,
|
my_person_id: Option<PersonId>,
|
||||||
is_mod_or_admin: bool,
|
is_mod_or_admin: bool,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let mut res = queries()
|
let res = queries()
|
||||||
.read(pool, (post_id, my_person_id, is_mod_or_admin))
|
.read(pool, (post_id, my_person_id, is_mod_or_admin))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// If a person is given, then my_vote, if None, should be 0, not null
|
|
||||||
// Necessary to differentiate between other person's votes
|
|
||||||
if my_person_id.is_some() && res.my_vote.is_none() {
|
|
||||||
res.my_vote = Some(0)
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -877,7 +871,7 @@ mod tests {
|
||||||
assert_eq!(1, read_post_listing.len());
|
assert_eq!(1, read_post_listing.len());
|
||||||
|
|
||||||
assert_eq!(expected_post_listing_with_user, read_post_listing[0]);
|
assert_eq!(expected_post_listing_with_user, read_post_listing[0]);
|
||||||
expected_post_listing_with_user.my_vote = Some(0);
|
expected_post_listing_with_user.my_vote = None;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
expected_post_listing_with_user,
|
expected_post_listing_with_user,
|
||||||
post_listing_single_with_person
|
post_listing_single_with_person
|
||||||
|
|
Loading…
Reference in New Issue