use crate::{
- newtypes::{CommentReportId, PersonId},
- schema::comment_report::dsl::{comment_report, resolved, resolver_id, updated},
+ newtypes::{CommentId, CommentReportId, PersonId},
+ schema::comment_report::{
+ comment_id,
+ dsl::{comment_report, resolved, resolver_id, updated},
+ },
source::comment_report::{CommentReport, CommentReportForm},
traits::Reportable,
utils::{get_conn, naive_now, DbPool},
impl Reportable for CommentReport {
type Form = CommentReportForm;
type IdType = CommentReportId;
+ type ObjectIdType = CommentId;
/// creates a comment report and returns it
///
/// * `conn` - the postgres connection
.await
}
+ async fn resolve_all_for_object(
+ pool: &mut DbPool<'_>,
+ comment_id_: CommentId,
+ by_resolver_id: PersonId,
+ ) -> Result<usize, Error> {
+ let conn = &mut get_conn(pool).await?;
+ update(comment_report.filter(comment_id.eq(comment_id_)))
+ .set((
+ resolved.eq(true),
+ resolver_id.eq(by_resolver_id),
+ updated.eq(naive_now()),
+ ))
+ .execute(conn)
+ .await
+ }
+
/// unresolve a comment report
///
/// * `conn` - the postgres connection