2 use diesel::{dsl::*, result::Error, *};
5 source::comment_report::{CommentReport, CommentReportForm},
8 impl Reportable<CommentReportForm> for CommentReport {
9 /// creates a comment report and returns it
11 /// * `conn` - the postgres connection
12 /// * `comment_report_form` - the filled CommentReportForm to insert
13 fn report(conn: &PgConnection, comment_report_form: &CommentReportForm) -> Result<Self, Error> {
14 use lemmy_db_schema::schema::comment_report::dsl::*;
15 insert_into(comment_report)
16 .values(comment_report_form)
17 .get_result::<Self>(conn)
20 /// resolve a comment report
22 /// * `conn` - the postgres connection
23 /// * `report_id` - the id of the report to resolve
24 /// * `by_resolver_id` - the id of the user resolving the report
25 fn resolve(conn: &PgConnection, report_id: i32, by_resolver_id: i32) -> Result<usize, Error> {
26 use lemmy_db_schema::schema::comment_report::dsl::*;
27 update(comment_report.find(report_id))
30 resolver_id.eq(by_resolver_id),
31 updated.eq(naive_now()),
36 /// unresolve a comment report
38 /// * `conn` - the postgres connection
39 /// * `report_id` - the id of the report to unresolve
40 /// * `by_resolver_id` - the id of the user unresolving the report
41 fn unresolve(conn: &PgConnection, report_id: i32, by_resolver_id: i32) -> Result<usize, Error> {
42 use lemmy_db_schema::schema::comment_report::dsl::*;
43 update(comment_report.find(report_id))
46 resolver_id.eq(by_resolver_id),
47 updated.eq(naive_now()),