Skip to content

Commit

Permalink
Show deleted and removed posts for profile views. Fixes #2624
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines committed Feb 13, 2023
1 parent 3bb98fc commit 5c2685f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crates/apub/src/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub(crate) async fn get_activity(

let sensitive = activity.sensitive.unwrap_or(true);
if !activity.local {
return Err(err_object_not_local());
Err(err_object_not_local())
} else if sensitive {
Ok(HttpResponse::Forbidden().finish())
} else {
Expand Down
20 changes: 12 additions & 8 deletions crates/db_views/src/post_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ impl<'a> PostQuery<'a> {
);
}

// If its for a specific person, show the removed / deleted
if let Some(creator_id) = self.creator_id {
query = query.filter(post::creator_id.eq(creator_id));
}
Expand Down Expand Up @@ -382,6 +381,17 @@ impl<'a> PostQuery<'a> {
query = query.filter(person_block::person_id.is_null());
}

// If you are not logged in, or its not profile fetch, hide the removed / deleted
// TODO This should join to the post::creator_id column, in order to only hide posts for
// others, but diesel doesn't currently have case when support
if self.local_user.is_none() || self.creator_id.is_none() {
query = query
.filter(post::removed.eq(false))
.filter(post::deleted.eq(false))
.filter(community::removed.eq(false))
.filter(community::deleted.eq(false));
}

query = match self.sort.unwrap_or(SortType::Hot) {
SortType::Active => query
.then_order_by(
Expand Down Expand Up @@ -424,13 +434,7 @@ impl<'a> PostQuery<'a> {

let (limit, offset) = limit_and_offset(self.page, self.limit)?;

query = query
.limit(limit)
.offset(offset)
.filter(post::removed.eq(false))
.filter(post::deleted.eq(false))
.filter(community::removed.eq(false))
.filter(community::deleted.eq(false));
query = query.limit(limit).offset(offset);

debug!("Post View Query: {:?}", debug_query::<Pg, _>(&query));

Expand Down

0 comments on commit 5c2685f

Please sign in to comment.