1 use crate::newtypes::{CommunityId, DbUrl, PersonId, PostId};
2 use serde::{Deserialize, Serialize};
4 #[cfg(feature = "full")]
5 use crate::schema::{post, post_like, post_read, post_saved};
7 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
8 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
9 #[cfg_attr(feature = "full", table_name = "post")]
13 pub url: Option<DbUrl>,
14 pub body: Option<String>,
15 pub creator_id: PersonId,
16 pub community_id: CommunityId,
19 pub published: chrono::NaiveDateTime,
20 pub updated: Option<chrono::NaiveDateTime>,
24 pub embed_title: Option<String>,
25 pub embed_description: Option<String>,
26 pub embed_video_url: Option<DbUrl>,
27 pub thumbnail_url: Option<DbUrl>,
33 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
34 #[cfg_attr(feature = "full", table_name = "post")]
37 pub creator_id: PersonId,
38 pub community_id: CommunityId,
39 pub nsfw: Option<bool>,
40 pub url: Option<Option<DbUrl>>,
41 pub body: Option<Option<String>>,
42 pub removed: Option<bool>,
43 pub locked: Option<bool>,
44 pub published: Option<chrono::NaiveDateTime>,
45 pub updated: Option<chrono::NaiveDateTime>,
46 pub deleted: Option<bool>,
47 pub stickied: Option<bool>,
48 pub embed_title: Option<Option<String>>,
49 pub embed_description: Option<Option<String>>,
50 pub embed_video_url: Option<Option<DbUrl>>,
51 pub thumbnail_url: Option<Option<DbUrl>>,
52 pub ap_id: Option<DbUrl>,
53 pub local: Option<bool>,
56 #[derive(PartialEq, Debug)]
57 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
58 #[cfg_attr(feature = "full", belongs_to(Post))]
59 #[cfg_attr(feature = "full", table_name = "post_like")]
63 pub person_id: PersonId,
65 pub published: chrono::NaiveDateTime,
69 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
70 #[cfg_attr(feature = "full", table_name = "post_like")]
71 pub struct PostLikeForm {
73 pub person_id: PersonId,
77 #[derive(PartialEq, Debug)]
78 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
79 #[cfg_attr(feature = "full", belongs_to(Post))]
80 #[cfg_attr(feature = "full", table_name = "post_saved")]
81 pub struct PostSaved {
84 pub person_id: PersonId,
85 pub published: chrono::NaiveDateTime,
88 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
89 #[cfg_attr(feature = "full", table_name = "post_saved")]
90 pub struct PostSavedForm {
92 pub person_id: PersonId,
95 #[derive(PartialEq, Debug)]
96 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
97 #[cfg_attr(feature = "full", belongs_to(Post))]
98 #[cfg_attr(feature = "full", table_name = "post_read")]
102 pub person_id: PersonId,
103 pub published: chrono::NaiveDateTime,
106 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
107 #[cfg_attr(feature = "full", table_name = "post_read")]
108 pub struct PostReadForm {
110 pub person_id: PersonId,