feat: add visibility check for tagging in thought creation
This commit is contained in:
@@ -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")))
|
||||
|
@@ -35,11 +35,13 @@ pub async fn create_thought(
|
||||
.insert(&txn)
|
||||
.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?;
|
||||
Ok(new_thought)
|
||||
|
Reference in New Issue
Block a user