Dont show deleted users or communities on profile page. (#2450)

* Dont show deleted users or communities on profile page.

- Fixes #2448

* Fix missing communities

* Add include_deleted to resolve_actor_identifier.
This commit is contained in:
Dessalines 2022-09-28 16:54:32 -04:00 committed by GitHub
parent ae95f5928e
commit ee41654394
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 16 additions and 6 deletions

View file

@ -51,7 +51,7 @@ impl Perform for Search {
let search_type = data.type_.unwrap_or(SearchType::All); let search_type = data.type_.unwrap_or(SearchType::All);
let community_id = data.community_id; let community_id = data.community_id;
let community_actor_id = if let Some(name) = &data.community_name { let community_actor_id = if let Some(name) = &data.community_name {
resolve_actor_identifier::<ApubCommunity, Community>(name, context) resolve_actor_identifier::<ApubCommunity, Community>(name, context, false)
.await .await
.ok() .ok()
.map(|c| c.actor_id) .map(|c| c.actor_id)

View file

@ -38,7 +38,7 @@ impl PerformCrud for GetComments {
let listing_type = listing_type_with_site_default(data.type_, context.pool()).await?; let listing_type = listing_type_with_site_default(data.type_, context.pool()).await?;
let community_actor_id = if let Some(name) = &data.community_name { let community_actor_id = if let Some(name) = &data.community_name {
resolve_actor_identifier::<ApubCommunity, Community>(name, context) resolve_actor_identifier::<ApubCommunity, Community>(name, context, true)
.await .await
.ok() .ok()
.map(|c| c.actor_id) .map(|c| c.actor_id)

View file

@ -43,7 +43,7 @@ impl PerformCrud for GetCommunity {
Some(id) => id, Some(id) => id,
None => { None => {
let name = data.name.to_owned().unwrap_or_else(|| "main".to_string()); let name = data.name.to_owned().unwrap_or_else(|| "main".to_string());
resolve_actor_identifier::<ApubCommunity, Community>(&name, context) resolve_actor_identifier::<ApubCommunity, Community>(&name, context, true)
.await .await
.map_err(|e| e.with_message("couldnt_find_community"))? .map_err(|e| e.with_message("couldnt_find_community"))?
.id .id

View file

@ -41,7 +41,7 @@ impl PerformCrud for GetPosts {
let limit = data.limit; let limit = data.limit;
let community_id = data.community_id; let community_id = data.community_id;
let community_actor_id = if let Some(name) = &data.community_name { let community_actor_id = if let Some(name) = &data.community_name {
resolve_actor_identifier::<ApubCommunity, Community>(name, context) resolve_actor_identifier::<ApubCommunity, Community>(name, context, true)
.await .await
.ok() .ok()
.map(|c| c.actor_id) .map(|c| c.actor_id)

View file

@ -37,7 +37,7 @@ impl PerformCrud for GetPersonDetails {
Some(id) => id, Some(id) => id,
None => { None => {
if let Some(username) = &data.username { if let Some(username) = &data.username {
resolve_actor_identifier::<ApubPerson, Person>(username, context) resolve_actor_identifier::<ApubPerson, Person>(username, context, true)
.await .await
.map_err(|e| e.with_message("couldnt_find_that_username_or_email"))? .map_err(|e| e.with_message("couldnt_find_that_username_or_email"))?
.id .id

View file

@ -18,6 +18,7 @@ pub mod webfinger;
pub async fn resolve_actor_identifier<Actor, DbActor>( pub async fn resolve_actor_identifier<Actor, DbActor>(
identifier: &str, identifier: &str,
context: &LemmyContext, context: &LemmyContext,
include_deleted: bool,
) -> Result<DbActor, LemmyError> ) -> Result<DbActor, LemmyError>
where where
Actor: ApubObject<DataType = LemmyContext, Error = LemmyError> Actor: ApubObject<DataType = LemmyContext, Error = LemmyError>
@ -58,7 +59,7 @@ where
let identifier = identifier.to_string(); let identifier = identifier.to_string();
Ok( Ok(
blocking(context.pool(), move |conn| { blocking(context.pool(), move |conn| {
DbActor::read_from_name(conn, &identifier, false) DbActor::read_from_name(conn, &identifier, include_deleted)
}) })
.await??, .await??,
) )

View file

@ -22,6 +22,8 @@ impl CommunityBlockView {
Community::safe_columns_tuple(), Community::safe_columns_tuple(),
)) ))
.filter(community_block::person_id.eq(person_id)) .filter(community_block::person_id.eq(person_id))
.filter(community::deleted.eq(false))
.filter(community::removed.eq(false))
.order_by(community_block::published) .order_by(community_block::published)
.load::<CommunityBlockViewTuple>(conn)?; .load::<CommunityBlockViewTuple>(conn)?;

View file

@ -40,6 +40,8 @@ impl CommunityFollowerView {
Person::safe_columns_tuple(), Person::safe_columns_tuple(),
)) ))
.filter(community_follower::person_id.eq(person_id)) .filter(community_follower::person_id.eq(person_id))
.filter(community::deleted.eq(false))
.filter(community::removed.eq(false))
.order_by(community::title) .order_by(community::title)
.load::<CommunityFollowerViewTuple>(conn)?; .load::<CommunityFollowerViewTuple>(conn)?;

View file

@ -40,6 +40,8 @@ impl CommunityModeratorView {
Person::safe_columns_tuple(), Person::safe_columns_tuple(),
)) ))
.filter(community_moderator::person_id.eq(person_id)) .filter(community_moderator::person_id.eq(person_id))
.filter(community::deleted.eq(false))
.filter(community::removed.eq(false))
.order_by(community_moderator::published) .order_by(community_moderator::published)
.load::<CommunityModeratorViewTuple>(conn)?; .load::<CommunityModeratorViewTuple>(conn)?;

View file

@ -21,6 +21,7 @@ impl PersonBlockView {
person_alias_1.fields(Person::safe_columns_tuple()), person_alias_1.fields(Person::safe_columns_tuple()),
)) ))
.filter(person_block::person_id.eq(person_id)) .filter(person_block::person_id.eq(person_id))
.filter(person_alias_1.field(person::deleted).eq(false))
.order_by(person_block::published) .order_by(person_block::published)
.load::<PersonBlockViewTuple>(conn)?; .load::<PersonBlockViewTuple>(conn)?;

View file

@ -28,6 +28,7 @@ impl PersonViewSafe {
.inner_join(person_aggregates::table) .inner_join(person_aggregates::table)
.select((Person::safe_columns_tuple(), person_aggregates::all_columns)) .select((Person::safe_columns_tuple(), person_aggregates::all_columns))
.filter(person::admin.eq(true)) .filter(person::admin.eq(true))
.filter(person::deleted.eq(false))
.order_by(person::published) .order_by(person::published)
.load::<PersonViewSafeTuple>(conn)?; .load::<PersonViewSafeTuple>(conn)?;
@ -45,6 +46,7 @@ impl PersonViewSafe {
.or(person::ban_expires.gt(now)), .or(person::ban_expires.gt(now)),
), ),
) )
.filter(person::deleted.eq(false))
.load::<PersonViewSafeTuple>(conn)?; .load::<PersonViewSafeTuple>(conn)?;
Ok(Self::from_tuple_to_vec(banned)) Ok(Self::from_tuple_to_vec(banned))