From 3d25ffca4f3fbd72342be8f43105412a12a10cdd Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Sun, 7 Sep 2025 15:15:24 +0200 Subject: [PATCH] feat: add visibility check for tagging in thought creation --- thoughts-backend/app/src/persistence/tag.rs | 1 + thoughts-backend/app/src/persistence/thought.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/thoughts-backend/app/src/persistence/tag.rs b/thoughts-backend/app/src/persistence/tag.rs index ddd92c0..79f03a5 100644 --- a/thoughts-backend/app/src/persistence/tag.rs +++ b/thoughts-backend/app/src/persistence/tag.rs @@ -106,6 +106,7 @@ where thought_tag::Relation::Thought.def(), ) .filter(thought::Column::CreatedAt.gte(seven_days_ago)) + .filter(thought::Column::Visibility.eq(thought::Visibility::Public)) .group_by(tag::Column::Name) .group_by(tag::Column::Id) .order_by_desc(Expr::col(Alias::new("count"))) diff --git a/thoughts-backend/app/src/persistence/thought.rs b/thoughts-backend/app/src/persistence/thought.rs index da63a12..24b237c 100644 --- a/thoughts-backend/app/src/persistence/thought.rs +++ b/thoughts-backend/app/src/persistence/thought.rs @@ -35,10 +35,12 @@ pub async fn create_thought( .insert(&txn) .await?; - let tag_names = parse_hashtags(¶ms.content); - if !tag_names.is_empty() { - let tags = find_or_create_tags(&txn, tag_names).await?; - link_tags_to_thought(&txn, new_thought.id, tags).await?; + if new_thought.visibility == thought::Visibility::Public { + let tag_names = parse_hashtags(¶ms.content); + if !tag_names.is_empty() { + let tags = find_or_create_tags(&txn, tag_names).await?; + link_tags_to_thought(&txn, new_thought.id, tags).await?; + } } txn.commit().await?;