diff --git a/crates/core/src/database/posts.rs b/crates/core/src/database/posts.rs index 3362e63..57df032 100644 --- a/crates/core/src/database/posts.rs +++ b/crates/core/src/database/posts.rs @@ -490,7 +490,7 @@ impl DataManager { let res = query_rows!( &conn, &format!( - "SELECT * FROM posts WHERE owner = $1 AND replying_to = 0 AND NOT (context::json->>'is_profile_pinned')::boolean {} ORDER BY created DESC LIMIT $2 OFFSET $3", + "SELECT * FROM posts WHERE owner = $1 AND replying_to = 0 AND NOT (context::json->>'is_profile_pinned')::boolean AND is_deleted = 0 {} ORDER BY created DESC LIMIT $2 OFFSET $3", if hide_nsfw { "AND NOT (context::json->>'is_nsfw')::boolean" } else { @@ -634,7 +634,7 @@ impl DataManager { let res = query_rows!( &conn, &format!( - "SELECT * FROM posts WHERE owner = $1 AND tsvector_content @@ to_tsquery($2) {} ORDER BY created DESC LIMIT $3 OFFSET $4", + "SELECT * FROM posts WHERE owner = $1 AND tsvector_content @@ to_tsquery($2) {} AND is_deleted = 0 ORDER BY created DESC LIMIT $3 OFFSET $4", if hide_nsfw { "AND NOT (context::json->>'is_nsfw')::boolean" } else { @@ -677,7 +677,7 @@ impl DataManager { // ... let res = query_rows!( &conn, - "SELECT * FROM posts WHERE tsvector_content @@ to_tsquery($1) ORDER BY created DESC LIMIT $2 OFFSET $3", + "SELECT * FROM posts WHERE tsvector_content @@ to_tsquery($1) AND is_deleted = 0 ORDER BY created DESC LIMIT $2 OFFSET $3", params![&text_query, &(batch as i64), &((page * batch) as i64)], |x| { Self::get_post_from_row(x) } ); @@ -720,7 +720,7 @@ impl DataManager { let res = query_rows!( &conn, &format!( - "SELECT * FROM posts WHERE owner = $1 AND context::json->>'tags' LIKE $2 {} ORDER BY created DESC LIMIT $3 OFFSET $4", + "SELECT * FROM posts WHERE owner = $1 AND context::json->>'tags' LIKE $2 AND is_deleted = 0 {} ORDER BY created DESC LIMIT $3 OFFSET $4", if hide_nsfw { "AND NOT (context::json->>'is_nsfw')::boolean" } else { @@ -762,7 +762,7 @@ impl DataManager { let res = query_rows!( &conn, - "SELECT * FROM posts WHERE community = $1 AND replying_to = 0 AND NOT context LIKE '%\"is_pinned\":true%' ORDER BY created DESC LIMIT $2 OFFSET $3", + "SELECT * FROM posts WHERE community = $1 AND replying_to = 0 AND NOT context LIKE '%\"is_pinned\":true%' AND is_deleted = 0 ORDER BY created DESC LIMIT $2 OFFSET $3", &[&(id as i64), &(batch as i64), &((page * batch) as i64)], |x| { Self::get_post_from_row(x) } ); @@ -841,7 +841,7 @@ impl DataManager { let res = query_rows!( &conn, - "SELECT * FROM posts WHERE context LIKE $1 ORDER BY created DESC LIMIT $2 OFFSET $3", + "SELECT * FROM posts WHERE context LIKE $1 AND is_deleted = 0 ORDER BY created DESC LIMIT $2 OFFSET $3", params![ &format!("%\"answering\":{id}%"), &(batch as i64), @@ -1053,7 +1053,7 @@ impl DataManager { let res = query_rows!( &conn, &format!( - "SELECT * FROM posts WHERE (community = {} {query_string}) AND NOT context LIKE '%\"is_nsfw\":true%' AND replying_to = 0 ORDER BY created DESC LIMIT $1 OFFSET $2", + "SELECT * FROM posts WHERE (community = {} {query_string}) AND NOT context LIKE '%\"is_nsfw\":true%' AND replying_to = 0 AND is_deleted = 0 ORDER BY created DESC LIMIT $1 OFFSET $2", first.community ), &[&(batch as i64), &((page * batch) as i64)], @@ -1101,7 +1101,7 @@ impl DataManager { let res = query_rows!( &conn, &format!( - "SELECT * FROM posts WHERE (owner = {} {query_string}) AND replying_to = 0 ORDER BY created DESC LIMIT $1 OFFSET $2", + "SELECT * FROM posts WHERE (owner = {} {query_string}) AND replying_to = 0 AND is_deleted = 0 ORDER BY created DESC LIMIT $1 OFFSET $2", first.receiver ), &[&(batch as i64), &((page * batch) as i64)], @@ -1151,7 +1151,7 @@ impl DataManager { let res = query_rows!( &conn, &format!( - "SELECT * FROM posts WHERE (owner = {} {query_string}) AND replying_to = 0 ORDER BY {} DESC LIMIT $1 OFFSET $2", + "SELECT * FROM posts WHERE (owner = {} {query_string}) AND replying_to = 0 AND is_deleted = 0 ORDER BY {} DESC LIMIT $1 OFFSET $2", first, if sort == StackSort::Created { "created"