+ .load::<CommentViewTuple>(&mut conn)
+ .await
+ };
+
+ Queries::new(read, list)
+}
+
+impl CommentView {
+ pub async fn read(
+ pool: &mut DbPool<'_>,
+ comment_id: CommentId,
+ my_person_id: Option<PersonId>,
+ ) -> Result<Self, Error> {
+ // If a person is given, then my_vote (res.9), if None, should be 0, not null
+ // Necessary to differentiate between other person's votes
+ let mut res = queries().read(pool, (comment_id, my_person_id)).await?;
+ if my_person_id.is_some() && res.my_vote.is_none() {
+ res.my_vote = Some(0);
+ }
+ Ok(res)
+ }
+}
+
+#[derive(Default)]
+pub struct CommentQuery<'a> {
+ pub listing_type: Option<ListingType>,
+ pub sort: Option<CommentSortType>,
+ pub community_id: Option<CommunityId>,
+ pub post_id: Option<PostId>,
+ pub parent_path: Option<Ltree>,
+ pub creator_id: Option<PersonId>,
+ pub local_user: Option<&'a LocalUserView>,
+ pub search_term: Option<String>,
+ pub saved_only: Option<bool>,
+ pub is_profile_view: Option<bool>,
+ pub show_deleted_and_removed: Option<bool>,
+ pub page: Option<i64>,
+ pub limit: Option<i64>,
+ pub max_depth: Option<i32>,
+}