mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-12-27 12:30:31 +00:00
Send Create activity when undrafting post
Send a Create activity when a post get undrafted, instead of sending an Update activity for a non federated post Fix #221
This commit is contained in:
parent
cbbd0ca920
commit
0bb2e6293a
1 changed files with 14 additions and 5 deletions
|
@ -192,10 +192,13 @@ fn update(blog: String, slug: String, user: User, conn: DbConn, data: LenientFor
|
|||
};
|
||||
|
||||
// update publication date if when this article is no longer a draft
|
||||
if !post.published && !form.draft {
|
||||
let newly_published = if !post.published && !form.draft {
|
||||
post.published = true;
|
||||
post.creation_date = Utc::now().naive_utc();
|
||||
}
|
||||
true
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
post.slug = new_slug.clone();
|
||||
post.title = form.title.clone();
|
||||
|
@ -246,9 +249,15 @@ fn update(blog: String, slug: String, user: User, conn: DbConn, data: LenientFor
|
|||
}
|
||||
|
||||
if post.published {
|
||||
let act = post.update_activity(&*conn);
|
||||
let dest = User::one_by_instance(&*conn);
|
||||
worker.execute(Thunk::of(move || broadcast(&user, act, dest)));
|
||||
if newly_published {
|
||||
let act = post.create_activity(&conn);
|
||||
let dest = User::one_by_instance(&*conn);
|
||||
worker.execute(Thunk::of(move || broadcast(&user, act, dest)));
|
||||
} else {
|
||||
let act = post.update_activity(&*conn);
|
||||
let dest = User::one_by_instance(&*conn);
|
||||
worker.execute(Thunk::of(move || broadcast(&user, act, dest)));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Redirect::to(uri!(details: blog = blog, slug = new_slug)))
|
||||
|
|
Loading…
Reference in a new issue