Add a cover field to posts
Referencing the media to use to illustrate the article
This commit is contained in:
@@ -44,6 +44,7 @@ pub struct Post {
|
||||
pub ap_url: String,
|
||||
pub subtitle: String,
|
||||
pub source: String,
|
||||
pub cover_id: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
@@ -59,6 +60,7 @@ pub struct NewPost {
|
||||
pub ap_url: String,
|
||||
pub subtitle: String,
|
||||
pub source: String,
|
||||
pub cover_id: Option<i32>,
|
||||
}
|
||||
|
||||
impl<'a> Provider<(&'a Connection, Option<i32>)> for Post {
|
||||
@@ -547,7 +549,8 @@ impl FromActivity<Article, Connection> for Post {
|
||||
ap_url: article.object_props.url_string().unwrap_or(article.object_props.id_string().expect("Post::from_activity: url + id error")),
|
||||
creation_date: Some(article.object_props.published_utctime().expect("Post::from_activity: published error").naive_utc()),
|
||||
subtitle: article.object_props.summary_string().expect("Post::from_activity: summary error"),
|
||||
source: article.ap_object_props.source_object::<Source>().expect("Post::from_activity: source error").content
|
||||
source: article.ap_object_props.source_object::<Source>().expect("Post::from_activity: source error").content,
|
||||
cover_id: None, // TODO
|
||||
});
|
||||
|
||||
for author in authors.into_iter() {
|
||||
|
||||
@@ -150,6 +150,7 @@ table! {
|
||||
ap_url -> Varchar,
|
||||
subtitle -> Text,
|
||||
source -> Text,
|
||||
cover_id -> Nullable<Int4>,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,6 +212,7 @@ joinable!(notifications -> users (user_id));
|
||||
joinable!(post_authors -> posts (post_id));
|
||||
joinable!(post_authors -> users (author_id));
|
||||
joinable!(posts -> blogs (blog_id));
|
||||
joinable!(posts -> medias (cover_id));
|
||||
joinable!(reshares -> posts (post_id));
|
||||
joinable!(reshares -> users (user_id));
|
||||
joinable!(tags -> posts (post_id));
|
||||
|
||||
Reference in New Issue
Block a user