From 35796c6e935946902698b18856adabe7d149ae6a Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 23 May 2024 23:27:45 +0200 Subject: [PATCH] fix: side effects only after inserting otherwise duplicate fetches will increment counter before being caught as duplicates --- src/server/normalizer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/normalizer.rs b/src/server/normalizer.rs index 88f5c572..263d4127 100644 --- a/src/server/normalizer.rs +++ b/src/server/normalizer.rs @@ -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,