///
/// * `report_id` - the report id to obtain
pub async fn read(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
report_id: CommentReportId,
my_person_id: PersonId,
) -> Result<Self, Error> {
community_person_ban::table.on(
community::id
.eq(community_person_ban::community_id)
- .and(community_person_ban::person_id.eq(comment::creator_id))
- .and(
- community_person_ban::expires
- .is_null()
- .or(community_person_ban::expires.gt(now)),
- ),
+ .and(community_person_ban::person_id.eq(comment::creator_id)),
),
)
.left_join(
/// Returns the current unresolved post report count for the communities you mod
pub async fn get_report_count(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
my_person_id: PersonId,
admin: bool,
community_id: Option<CommunityId>,
#[derive(TypedBuilder)]
#[builder(field_defaults(default))]
-pub struct CommentReportQuery<'a> {
+pub struct CommentReportQuery<'a, 'b: 'a> {
#[builder(!default)]
- pool: &'a DbPool,
+ pool: &'a mut DbPool<'b>,
#[builder(!default)]
my_person_id: PersonId,
#[builder(!default)]
unresolved_only: Option<bool>,
}
-impl<'a> CommentReportQuery<'a> {
+impl<'a, 'b: 'a> CommentReportQuery<'a, 'b> {
pub async fn list(self) -> Result<Vec<CommentReportView>, Error> {
let conn = &mut get_conn(self.pool).await?;
query = query.filter(post::community_id.eq(community_id));
}
- if self.unresolved_only.unwrap_or(true) {
+ if self.unresolved_only.unwrap_or(false) {
query = query.filter(comment_report::resolved.eq(false));
}
#[serial]
async fn test_crud() {
let pool = &build_db_pool_for_tests().await;
+ let pool = &mut pool.into();
let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string())
.await
downvotes: 0,
published: agg.published,
child_count: 0,
+ hot_rank: 1728,
},
my_vote: None,
resolver: None,
.pool(pool)
.my_person_id(inserted_timmy.id)
.admin(false)
+ .unresolved_only(Some(true))
.build()
.list()
.await