]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/private_message.rs
Diesel 2.0.0 upgrade (#2452)
[lemmy.git] / crates / db_schema / src / source / private_message.rs
1 use crate::newtypes::{DbUrl, PersonId, PrivateMessageId};
2 use serde::{Deserialize, Serialize};
3
4 #[cfg(feature = "full")]
5 use crate::schema::private_message;
6
7 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
8 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
9 #[cfg_attr(
10   feature = "full",
11   diesel(belongs_to(crate::source::person::Person, foreign_key = creator_id)
12 ))] // Is this the right assoc?
13 #[cfg_attr(feature = "full", diesel(table_name = private_message))]
14 pub struct PrivateMessage {
15   pub id: PrivateMessageId,
16   pub creator_id: PersonId,
17   pub recipient_id: PersonId,
18   pub content: String,
19   pub deleted: bool,
20   pub read: bool,
21   pub published: chrono::NaiveDateTime,
22   pub updated: Option<chrono::NaiveDateTime>,
23   pub ap_id: DbUrl,
24   pub local: bool,
25 }
26
27 #[derive(Default)]
28 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
29 #[cfg_attr(feature = "full", diesel(table_name = private_message))]
30 pub struct PrivateMessageForm {
31   pub creator_id: PersonId,
32   pub recipient_id: PersonId,
33   pub content: String,
34   pub deleted: Option<bool>,
35   pub read: Option<bool>,
36   pub published: Option<chrono::NaiveDateTime>,
37   pub updated: Option<chrono::NaiveDateTime>,
38   pub ap_id: Option<DbUrl>,
39   pub local: Option<bool>,
40 }