feat: add visibility check for tagging in thought creation

This commit is contained in:
2025-09-07 15:15:24 +02:00
parent 5ce6d9f2da
commit 3d25ffca4f
2 changed files with 7 additions and 4 deletions

View File

@@ -106,6 +106,7 @@ where
thought_tag::Relation::Thought.def(), thought_tag::Relation::Thought.def(),
) )
.filter(thought::Column::CreatedAt.gte(seven_days_ago)) .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::Name)
.group_by(tag::Column::Id) .group_by(tag::Column::Id)
.order_by_desc(Expr::col(Alias::new("count"))) .order_by_desc(Expr::col(Alias::new("count")))

View File

@@ -35,11 +35,13 @@ pub async fn create_thought(
.insert(&txn) .insert(&txn)
.await?; .await?;
if new_thought.visibility == thought::Visibility::Public {
let tag_names = parse_hashtags(&params.content); let tag_names = parse_hashtags(&params.content);
if !tag_names.is_empty() { if !tag_names.is_empty() {
let tags = find_or_create_tags(&txn, tag_names).await?; let tags = find_or_create_tags(&txn, tag_names).await?;
link_tags_to_thought(&txn, new_thought.id, tags).await?; link_tags_to_thought(&txn, new_thought.id, tags).await?;
} }
}
txn.commit().await?; txn.commit().await?;
Ok(new_thought) Ok(new_thought)