Hide replies from profile feed

This commit is contained in:
silverpill 2021-11-01 20:49:36 +00:00
parent ab9184f068
commit 64dddf3f7e
2 changed files with 13 additions and 4 deletions

View file

@ -187,7 +187,7 @@ async fn get_account_statuses(
Some(auth) => Some(get_current_user(db_client, auth.token()).await?),
None => None,
};
let mut posts = get_posts_by_author(db_client, &account_id).await?;
let mut posts = get_posts_by_author(db_client, &account_id, false).await?;
if let Some(user) = maybe_current_user {
get_actions_for_posts(
db_client,

View file

@ -53,8 +53,14 @@ pub async fn get_posts(
pub async fn get_posts_by_author(
db_client: &impl GenericClient,
account_id: &Uuid,
include_replies: bool,
) -> Result<Vec<Post>, DatabaseError> {
let rows = db_client.query(
let condition = if include_replies {
"post.author_id = $1"
} else {
"post.author_id = $1 AND post.in_reply_to_id IS NULL"
};
let statement = format!(
"
SELECT
post, actor_profile,
@ -64,10 +70,13 @@ pub async fn get_posts_by_author(
) AS attachments
FROM post
JOIN actor_profile ON post.author_id = actor_profile.id
WHERE
post.author_id = $1
WHERE {condition}
ORDER BY post.created_at DESC
",
condition=condition,
);
let rows = db_client.query(
statement.as_str(),
&[&account_id],
).await?;
let posts: Vec<Post> = rows.iter()