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