2 use diesel::{dsl::*, result::Error, *};
3 use lemmy_db_schema::{naive_now, source::post_report::*, PersonId};
5 impl Reportable for PostReport {
6 type Form = PostReportForm;
7 /// creates a post report and returns it
9 /// * `conn` - the postgres connection
10 /// * `post_report_form` - the filled CommentReportForm to insert
11 fn report(conn: &PgConnection, post_report_form: &PostReportForm) -> Result<Self, Error> {
12 use lemmy_db_schema::schema::post_report::dsl::*;
13 insert_into(post_report)
14 .values(post_report_form)
15 .get_result::<Self>(conn)
18 /// resolve a post report
20 /// * `conn` - the postgres connection
21 /// * `report_id` - the id of the report to resolve
22 /// * `by_resolver_id` - the id of the user resolving the report
26 by_resolver_id: PersonId,
27 ) -> Result<usize, Error> {
28 use lemmy_db_schema::schema::post_report::dsl::*;
29 update(post_report.find(report_id))
32 resolver_id.eq(by_resolver_id),
33 updated.eq(naive_now()),
38 /// resolve a post report
40 /// * `conn` - the postgres connection
41 /// * `report_id` - the id of the report to unresolve
42 /// * `by_resolver_id` - the id of the user unresolving the report
46 by_resolver_id: PersonId,
47 ) -> Result<usize, Error> {
48 use lemmy_db_schema::schema::post_report::dsl::*;
49 update(post_report.find(report_id))
52 resolver_id.eq(by_resolver_id),
53 updated.eq(naive_now()),