.into_boxed();
// Hide deleted and removed for non-admins or mods
- if !is_mod_or_admin.unwrap_or(true) {
+ if !is_mod_or_admin.unwrap_or(false) {
query = query
.filter(community::removed.eq(false))
- .filter(community::deleted.eq(false));
+ .filter(community::deleted.eq(false))
+ .filter(post::removed.eq(false))
+ .filter(post::deleted.eq(false));
}
let (
// Hide deleted and removed for non-admins or mods
// TODO This eventually needs to show posts where you are the creator
- if !self.is_mod_or_admin.unwrap_or(true) {
+ if !self.is_mod_or_admin.unwrap_or(false) {
query = query
.filter(community::removed.eq(false))
- .filter(community::deleted.eq(false));
+ .filter(community::deleted.eq(false))
+ .filter(post::removed.eq(false))
+ .filter(post::deleted.eq(false));
}
if self.community_id.is_none() {
local_user::{LocalUser, LocalUserInsertForm, LocalUserUpdateForm},
person::{Person, PersonInsertForm},
person_block::{PersonBlock, PersonBlockForm},
- post::{Post, PostInsertForm, PostLike, PostLikeForm},
+ post::{Post, PostInsertForm, PostLike, PostLikeForm, PostUpdateForm},
},
traits::{Blockable, Crud, Likeable},
utils::{build_db_pool_for_tests, DbPool},
cleanup(data, pool).await;
}
+ #[tokio::test]
+ #[serial]
+ async fn post_listings_deleted() {
+ let pool = &build_db_pool_for_tests().await;
+ let data = init_data(pool).await;
+
+ // Delete the post
+ Post::update(
+ pool,
+ data.inserted_post.id,
+ &PostUpdateForm::builder().deleted(Some(true)).build(),
+ )
+ .await
+ .unwrap();
+
+ // Make sure you don't see the deleted post in the results
+ let post_listings_no_admin = PostQuery::builder()
+ .pool(pool)
+ .sort(Some(SortType::New))
+ .local_user(Some(&data.inserted_local_user))
+ .is_mod_or_admin(Some(false))
+ .build()
+ .list()
+ .await
+ .unwrap();
+
+ assert_eq!(1, post_listings_no_admin.len());
+
+ // Make sure they see both
+ let post_listings_is_admin = PostQuery::builder()
+ .pool(pool)
+ .sort(Some(SortType::New))
+ .local_user(Some(&data.inserted_local_user))
+ .is_mod_or_admin(Some(true))
+ .build()
+ .list()
+ .await
+ .unwrap();
+
+ assert_eq!(2, post_listings_is_admin.len());
+
+ cleanup(data, pool).await;
+ }
+
async fn cleanup(data: Data, pool: &DbPool) {
let num_deleted = Post::delete(pool, data.inserted_post.id).await.unwrap();
Community::delete(pool, data.inserted_community.id)
.into_boxed();
// Hide deleted and removed for non-admins or mods
- if !is_mod_or_admin.unwrap_or(true) {
+ if !is_mod_or_admin.unwrap_or(false) {
query = query
.filter(community::removed.eq(false))
.filter(community::deleted.eq(false));
};
// Hide deleted and removed for non-admins or mods
- if !self.is_mod_or_admin.unwrap_or(true) {
+ if !self.is_mod_or_admin.unwrap_or(false) {
query = query
.filter(community::removed.eq(false))
.filter(community::deleted.eq(false))
let res = query
.limit(limit)
.offset(offset)
- .filter(community::removed.eq(false))
- .filter(community::deleted.eq(false))
.load::<CommunityViewTuple>(conn)
.await?;