1 use crate::newtypes::{CommunityId, DbUrl, LanguageId, 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, Eq, Debug, Serialize, Deserialize)]
8 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
9 #[cfg_attr(feature = "full", diesel(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>,
30 pub language_id: LanguageId,
34 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
35 #[cfg_attr(feature = "full", diesel(table_name = post))]
38 pub creator_id: PersonId,
39 pub community_id: CommunityId,
40 pub nsfw: Option<bool>,
41 pub url: Option<Option<DbUrl>>,
42 pub body: Option<Option<String>>,
43 pub removed: Option<bool>,
44 pub locked: Option<bool>,
45 pub published: Option<chrono::NaiveDateTime>,
46 pub updated: Option<chrono::NaiveDateTime>,
47 pub deleted: Option<bool>,
48 pub stickied: Option<bool>,
49 pub embed_title: Option<Option<String>>,
50 pub embed_description: Option<Option<String>>,
51 pub embed_video_url: Option<Option<DbUrl>>,
52 pub thumbnail_url: Option<Option<DbUrl>>,
53 pub ap_id: Option<DbUrl>,
54 pub local: Option<bool>,
55 pub language_id: Option<LanguageId>,
58 #[derive(PartialEq, Eq, Debug)]
59 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
60 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))]
61 #[cfg_attr(feature = "full", diesel(table_name = post_like))]
65 pub person_id: PersonId,
67 pub published: chrono::NaiveDateTime,
71 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
72 #[cfg_attr(feature = "full", diesel(table_name = post_like))]
73 pub struct PostLikeForm {
75 pub person_id: PersonId,
79 #[derive(PartialEq, Eq, Debug)]
80 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
81 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))]
82 #[cfg_attr(feature = "full", diesel(table_name = post_saved))]
83 pub struct PostSaved {
86 pub person_id: PersonId,
87 pub published: chrono::NaiveDateTime,
90 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
91 #[cfg_attr(feature = "full", diesel(table_name = post_saved))]
92 pub struct PostSavedForm {
94 pub person_id: PersonId,
97 #[derive(PartialEq, Eq, Debug)]
98 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
99 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))]
100 #[cfg_attr(feature = "full", diesel(table_name = post_read))]
101 pub struct PostRead {
104 pub person_id: PersonId,
105 pub published: chrono::NaiveDateTime,
108 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
109 #[cfg_attr(feature = "full", diesel(table_name = post_read))]
110 pub struct PostReadForm {
112 pub person_id: PersonId,