Save remote post only when it doesn't exist on local
This commit is contained in:
parent
9345a1b7a9
commit
37cbf537bb
@ -637,6 +637,7 @@ impl FromId<DbConn> for Post {
|
||||
}
|
||||
});
|
||||
|
||||
let post = Self::from_db(conn, &article.object_props.id_string()?).or_else(|_| {
|
||||
let cover = article
|
||||
.object_props
|
||||
.icon_object::<Image>()
|
||||
@ -644,7 +645,7 @@ impl FromId<DbConn> for Post {
|
||||
.and_then(|img| Media::from_activity(conn, &img).ok().map(|m| m.id));
|
||||
|
||||
let title = article.object_props.name_string()?;
|
||||
let post = Post::insert(
|
||||
Self::insert(
|
||||
conn,
|
||||
NewPost {
|
||||
blog_id: blog?.id,
|
||||
@ -663,7 +664,10 @@ impl FromId<DbConn> for Post {
|
||||
source: article.ap_object_props.source_object::<Source>()?.content,
|
||||
cover_id: cover,
|
||||
},
|
||||
)?;
|
||||
)
|
||||
})?;
|
||||
|
||||
// TODO: Update cover image if post's cover changes
|
||||
|
||||
for author in authors {
|
||||
PostAuthor::insert(
|
||||
|
Loading…
Reference in New Issue
Block a user