fix: side effects only after inserting

otherwise duplicate fetches will increment counter before being caught
as duplicates
This commit is contained in:
əlemi 2024-05-23 23:27:45 +02:00
parent 2442872b5f
commit 35796c6e93
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -42,6 +42,8 @@ impl Normalizer for super::Context {
(_, Some(_)) => {}, // leave it as set by user
}
model::object::Entity::insert(object_model.clone().into_active_model()).exec(self.db()).await?;
// update replies counter
if let Some(ref in_reply_to) = object_model.in_reply_to {
if self.fetch_object(in_reply_to).await.is_ok() {
@ -61,8 +63,6 @@ impl Normalizer for super::Context {
.await?;
}
model::object::Entity::insert(object_model.clone().into_active_model()).exec(self.db()).await?;
for attachment in object_node.attachment().flat() {
let attachment_model = match attachment {
Node::Empty => continue,