Hide direct messages from profile timeline

This commit is contained in:
silverpill 2021-11-19 00:32:22 +00:00
parent bbf696fe6e
commit cf5d4db031
2 changed files with 18 additions and 6 deletions

View file

@ -260,7 +260,12 @@ 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, false).await?; let mut posts = get_posts_by_author(
db_client,
&account_id,
false,
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

@ -14,7 +14,7 @@ use crate::models::cleanup::{
use crate::models::notifications::queries::create_reply_notification; use crate::models::notifications::queries::create_reply_notification;
use crate::models::profiles::queries::update_post_count; use crate::models::profiles::queries::update_post_count;
use crate::models::profiles::types::DbActorProfile; use crate::models::profiles::types::DbActorProfile;
use super::types::{DbPost, Post, PostCreateData}; use super::types::{DbPost, Post, PostCreateData, Visibility};
pub const RELATED_ATTACHMENTS: &str = pub const RELATED_ATTACHMENTS: &str =
"ARRAY( "ARRAY(
@ -72,11 +72,18 @@ pub async fn get_posts_by_author(
db_client: &impl GenericClient, db_client: &impl GenericClient,
account_id: &Uuid, account_id: &Uuid,
include_replies: bool, include_replies: bool,
include_private: bool,
) -> Result<Vec<Post>, DatabaseError> { ) -> Result<Vec<Post>, DatabaseError> {
let condition = if include_replies { let mut condition = "post.author_id = $1".to_string();
"post.author_id = $1" if !include_replies {
} else { condition.push_str(" AND post.in_reply_to_id IS NULL");
"post.author_id = $1 AND post.in_reply_to_id IS NULL" };
if !include_private {
let only_public = format!(
" AND visibility = {}",
i16::from(&Visibility::Public),
);
condition.push_str(&only_public);
}; };
let statement = format!( let statement = format!(
" "