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?), Some(auth) => Some(get_current_user(db_client, auth.token()).await?),
None => None, 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 { if let Some(user) = maybe_current_user {
get_actions_for_posts( get_actions_for_posts(
db_client, db_client,

View file

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