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
17 conn: &mut PgConnection,
18 pm_report_form: &PrivateMessageReportForm,
19 ) -> Result<Self, Error> {
20 use crate::schema::private_message_report::dsl::*;
21 insert_into(private_message_report)
22 .values(pm_report_form)
23 .get_result::<Self>(conn)
26 /// resolve a pm report
28 /// * `conn` - the postgres connection
29 /// * `report_id` - the id of the report to resolve
30 /// * `by_resolver_id` - the id of the user resolving the report
32 conn: &mut PgConnection,
33 report_id: Self::IdType,
34 by_resolver_id: PersonId,
35 ) -> Result<usize, Error> {
36 use crate::schema::private_message_report::dsl::*;
37 update(private_message_report.find(report_id))
40 resolver_id.eq(by_resolver_id),
41 updated.eq(naive_now()),
46 /// unresolve a comment report
48 /// * `conn` - the postgres connection
49 /// * `report_id` - the id of the report to unresolve
50 /// * `by_resolver_id` - the id of the user unresolving the report
52 conn: &mut PgConnection,
53 report_id: Self::IdType,
54 by_resolver_id: PersonId,
55 ) -> Result<usize, Error> {
56 use crate::schema::private_message_report::dsl::*;
57 update(private_message_report.find(report_id))
60 resolver_id.eq(by_resolver_id),
61 updated.eq(naive_now()),