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