2 use diesel::{dsl::*, result::Error, *};
5 source::comment_report::{CommentReport, CommentReportForm},
9 impl Reportable<CommentReportForm> for CommentReport {
10 /// creates a comment report and returns it
12 /// * `conn` - the postgres connection
13 /// * `comment_report_form` - the filled CommentReportForm to insert
14 fn report(conn: &PgConnection, comment_report_form: &CommentReportForm) -> Result<Self, Error> {
15 use lemmy_db_schema::schema::comment_report::dsl::*;
16 insert_into(comment_report)
17 .values(comment_report_form)
18 .get_result::<Self>(conn)
21 /// resolve a comment report
23 /// * `conn` - the postgres connection
24 /// * `report_id` - the id of the report to resolve
25 /// * `by_resolver_id` - the id of the user resolving the report
29 by_resolver_id: PersonId,
30 ) -> Result<usize, Error> {
31 use lemmy_db_schema::schema::comment_report::dsl::*;
32 update(comment_report.find(report_id))
35 resolver_id.eq(by_resolver_id),
36 updated.eq(naive_now()),
41 /// unresolve a comment report
43 /// * `conn` - the postgres connection
44 /// * `report_id` - the id of the report to unresolve
45 /// * `by_resolver_id` - the id of the user unresolving the report
49 by_resolver_id: PersonId,
50 ) -> Result<usize, Error> {
51 use lemmy_db_schema::schema::comment_report::dsl::*;
52 update(comment_report.find(report_id))
55 resolver_id.eq(by_resolver_id),
56 updated.eq(naive_now()),