feat: add visibility check for tagging in thought creation
This commit is contained in:
@@ -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")))
|
||||||
|
@@ -35,10 +35,12 @@ pub async fn create_thought(
|
|||||||
.insert(&txn)
|
.insert(&txn)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let tag_names = parse_hashtags(¶ms.content);
|
if new_thought.visibility == thought::Visibility::Public {
|
||||||
if !tag_names.is_empty() {
|
let tag_names = parse_hashtags(¶ms.content);
|
||||||
let tags = find_or_create_tags(&txn, tag_names).await?;
|
if !tag_names.is_empty() {
|
||||||
link_tags_to_thought(&txn, new_thought.id, tags).await?;
|
let tags = find_or_create_tags(&txn, tag_names).await?;
|
||||||
|
link_tags_to_thought(&txn, new_thought.id, tags).await?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
txn.commit().await?;
|
txn.commit().await?;
|
||||||
|
Reference in New Issue
Block a user