2 use diesel::{dsl::*, result::Error, *};
3 use lemmy_db_schema::{naive_now, source::post_report::*, PersonId, PostReportId};
5 impl Reportable for PostReport {
6 type Form = PostReportForm;
7 type IdType = PostReportId;
9 /// creates a post report and returns it
11 /// * `conn` - the postgres connection
12 /// * `post_report_form` - the filled CommentReportForm to insert
13 fn report(conn: &PgConnection, post_report_form: &PostReportForm) -> Result<Self, Error> {
14 use lemmy_db_schema::schema::post_report::dsl::*;
15 insert_into(post_report)
16 .values(post_report_form)
17 .get_result::<Self>(conn)
20 /// resolve a post 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
27 report_id: Self::IdType,
28 by_resolver_id: PersonId,
29 ) -> Result<usize, Error> {
30 use lemmy_db_schema::schema::post_report::dsl::*;
31 update(post_report.find(report_id))
34 resolver_id.eq(by_resolver_id),
35 updated.eq(naive_now()),
40 /// resolve a post report
42 /// * `conn` - the postgres connection
43 /// * `report_id` - the id of the report to unresolve
44 /// * `by_resolver_id` - the id of the user unresolving the report
47 report_id: Self::IdType,
48 by_resolver_id: PersonId,
49 ) -> Result<usize, Error> {
50 use lemmy_db_schema::schema::post_report::dsl::*;
51 update(post_report.find(report_id))
54 resolver_id.eq(by_resolver_id),
55 updated.eq(naive_now()),