2 use diesel::{dsl::*, result::Error, *};
5 source::comment_report::{CommentReport, CommentReportForm},
10 impl Reportable for CommentReport {
11 type Form = CommentReportForm;
12 type IdType = CommentReportId;
13 /// creates a comment report and returns it
15 /// * `conn` - the postgres connection
16 /// * `comment_report_form` - the filled CommentReportForm to insert
17 fn report(conn: &PgConnection, comment_report_form: &CommentReportForm) -> Result<Self, Error> {
18 use lemmy_db_schema::schema::comment_report::dsl::*;
19 insert_into(comment_report)
20 .values(comment_report_form)
21 .get_result::<Self>(conn)
24 /// resolve a comment report
26 /// * `conn` - the postgres connection
27 /// * `report_id` - the id of the report to resolve
28 /// * `by_resolver_id` - the id of the user resolving the report
31 report_id: Self::IdType,
32 by_resolver_id: PersonId,
33 ) -> Result<usize, Error> {
34 use lemmy_db_schema::schema::comment_report::dsl::*;
35 update(comment_report.find(report_id))
38 resolver_id.eq(by_resolver_id),
39 updated.eq(naive_now()),
44 /// unresolve a comment report
46 /// * `conn` - the postgres connection
47 /// * `report_id` - the id of the report to unresolve
48 /// * `by_resolver_id` - the id of the user unresolving the report
51 report_id: Self::IdType,
52 by_resolver_id: PersonId,
53 ) -> Result<usize, Error> {
54 use lemmy_db_schema::schema::comment_report::dsl::*;
55 update(comment_report.find(report_id))
58 resolver_id.eq(by_resolver_id),
59 updated.eq(naive_now()),