1 use crate::schema::{post, post_like, post_read, post_saved};
3 use url::{ParseError, Url};
5 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
10 pub url: Option<String>,
11 pub body: Option<String>,
13 pub community_id: i32,
16 pub published: chrono::NaiveDateTime,
17 pub updated: Option<chrono::NaiveDateTime>,
21 pub embed_title: Option<String>,
22 pub embed_description: Option<String>,
23 pub embed_html: Option<String>,
24 pub thumbnail_url: Option<String>,
29 #[derive(Insertable, AsChangeset)]
30 #[table_name = "post"]
33 pub url: Option<String>,
34 pub body: Option<String>,
36 pub community_id: i32,
37 pub removed: Option<bool>,
38 pub locked: Option<bool>,
39 pub published: Option<chrono::NaiveDateTime>,
40 pub updated: Option<chrono::NaiveDateTime>,
41 pub deleted: Option<bool>,
43 pub stickied: Option<bool>,
44 pub embed_title: Option<String>,
45 pub embed_description: Option<String>,
46 pub embed_html: Option<String>,
47 pub thumbnail_url: Option<String>,
48 pub ap_id: Option<String>,
53 pub fn get_ap_id(&self) -> Result<Url, ParseError> {
54 Url::parse(&self.ap_id.as_ref().unwrap_or(&"not_a_url".to_string()))
58 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
60 #[table_name = "post_like"]
66 pub published: chrono::NaiveDateTime,
69 #[derive(Insertable, AsChangeset, Clone)]
70 #[table_name = "post_like"]
71 pub struct PostLikeForm {
77 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
79 #[table_name = "post_saved"]
80 pub struct PostSaved {
84 pub published: chrono::NaiveDateTime,
87 #[derive(Insertable, AsChangeset)]
88 #[table_name = "post_saved"]
89 pub struct PostSavedForm {
94 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
96 #[table_name = "post_read"]
104 pub published: chrono::NaiveDateTime,
107 #[derive(Insertable, AsChangeset)]
108 #[table_name = "post_read"]
109 pub struct PostReadForm {