2 newtypes::{PersonId, PrivateMessageReportId},
3 source::private_message_report::{PrivateMessageReport, PrivateMessageReportForm},
7 use diesel::{dsl::*, result::Error, *};
9 impl Reportable for PrivateMessageReport {
10 type Form = PrivateMessageReportForm;
11 type IdType = PrivateMessageReportId;
12 /// creates a comment report and returns it
14 /// * `conn` - the postgres connection
15 /// * `comment_report_form` - the filled CommentReportForm to insert
16 fn report(conn: &PgConnection, pm_report_form: &PrivateMessageReportForm) -> Result<Self, Error> {
17 use crate::schema::private_message_report::dsl::*;
18 insert_into(private_message_report)
19 .values(pm_report_form)
20 .get_result::<Self>(conn)
23 /// resolve a pm report
25 /// * `conn` - the postgres connection
26 /// * `report_id` - the id of the report to resolve
27 /// * `by_resolver_id` - the id of the user resolving the report
30 report_id: Self::IdType,
31 by_resolver_id: PersonId,
32 ) -> Result<usize, Error> {
33 use crate::schema::private_message_report::dsl::*;
34 update(private_message_report.find(report_id))
37 resolver_id.eq(by_resolver_id),
38 updated.eq(naive_now()),
43 /// unresolve a comment report
45 /// * `conn` - the postgres connection
46 /// * `report_id` - the id of the report to unresolve
47 /// * `by_resolver_id` - the id of the user unresolving the report
50 report_id: Self::IdType,
51 by_resolver_id: PersonId,
52 ) -> Result<usize, Error> {
53 use crate::schema::private_message_report::dsl::*;
54 update(private_message_report.find(report_id))
57 resolver_id.eq(by_resolver_id),
58 updated.eq(naive_now()),