mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-10 06:54:12 +00:00
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:
parent
ae95f5928e
commit
ee41654394
11 changed files with 16 additions and 6 deletions
|
@ -51,7 +51,7 @@ impl Perform for Search {
|
|||
let search_type = data.type_.unwrap_or(SearchType::All);
|
||||
let community_id = data.community_id;
|
||||
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
|
||||
.ok()
|
||||
.map(|c| c.actor_id)
|
||||
|
|
|
@ -38,7 +38,7 @@ impl PerformCrud for GetComments {
|
|||
let listing_type = listing_type_with_site_default(data.type_, context.pool()).await?;
|
||||
|
||||
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
|
||||
.ok()
|
||||
.map(|c| c.actor_id)
|
||||
|
|
|
@ -43,7 +43,7 @@ impl PerformCrud for GetCommunity {
|
|||
Some(id) => id,
|
||||
None => {
|
||||
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
|
||||
.map_err(|e| e.with_message("couldnt_find_community"))?
|
||||
.id
|
||||
|
|
|
@ -41,7 +41,7 @@ impl PerformCrud for GetPosts {
|
|||
let limit = data.limit;
|
||||
let community_id = data.community_id;
|
||||
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
|
||||
.ok()
|
||||
.map(|c| c.actor_id)
|
||||
|
|
|
@ -37,7 +37,7 @@ impl PerformCrud for GetPersonDetails {
|
|||
Some(id) => id,
|
||||
None => {
|
||||
if let Some(username) = &data.username {
|
||||
resolve_actor_identifier::<ApubPerson, Person>(username, context)
|
||||
resolve_actor_identifier::<ApubPerson, Person>(username, context, true)
|
||||
.await
|
||||
.map_err(|e| e.with_message("couldnt_find_that_username_or_email"))?
|
||||
.id
|
||||
|
|
|
@ -18,6 +18,7 @@ pub mod webfinger;
|
|||
pub async fn resolve_actor_identifier<Actor, DbActor>(
|
||||
identifier: &str,
|
||||
context: &LemmyContext,
|
||||
include_deleted: bool,
|
||||
) -> Result<DbActor, LemmyError>
|
||||
where
|
||||
Actor: ApubObject<DataType = LemmyContext, Error = LemmyError>
|
||||
|
@ -58,7 +59,7 @@ where
|
|||
let identifier = identifier.to_string();
|
||||
Ok(
|
||||
blocking(context.pool(), move |conn| {
|
||||
DbActor::read_from_name(conn, &identifier, false)
|
||||
DbActor::read_from_name(conn, &identifier, include_deleted)
|
||||
})
|
||||
.await??,
|
||||
)
|
||||
|
|
|
@ -22,6 +22,8 @@ impl CommunityBlockView {
|
|||
Community::safe_columns_tuple(),
|
||||
))
|
||||
.filter(community_block::person_id.eq(person_id))
|
||||
.filter(community::deleted.eq(false))
|
||||
.filter(community::removed.eq(false))
|
||||
.order_by(community_block::published)
|
||||
.load::<CommunityBlockViewTuple>(conn)?;
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ impl CommunityFollowerView {
|
|||
Person::safe_columns_tuple(),
|
||||
))
|
||||
.filter(community_follower::person_id.eq(person_id))
|
||||
.filter(community::deleted.eq(false))
|
||||
.filter(community::removed.eq(false))
|
||||
.order_by(community::title)
|
||||
.load::<CommunityFollowerViewTuple>(conn)?;
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ impl CommunityModeratorView {
|
|||
Person::safe_columns_tuple(),
|
||||
))
|
||||
.filter(community_moderator::person_id.eq(person_id))
|
||||
.filter(community::deleted.eq(false))
|
||||
.filter(community::removed.eq(false))
|
||||
.order_by(community_moderator::published)
|
||||
.load::<CommunityModeratorViewTuple>(conn)?;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ impl PersonBlockView {
|
|||
person_alias_1.fields(Person::safe_columns_tuple()),
|
||||
))
|
||||
.filter(person_block::person_id.eq(person_id))
|
||||
.filter(person_alias_1.field(person::deleted).eq(false))
|
||||
.order_by(person_block::published)
|
||||
.load::<PersonBlockViewTuple>(conn)?;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ impl PersonViewSafe {
|
|||
.inner_join(person_aggregates::table)
|
||||
.select((Person::safe_columns_tuple(), person_aggregates::all_columns))
|
||||
.filter(person::admin.eq(true))
|
||||
.filter(person::deleted.eq(false))
|
||||
.order_by(person::published)
|
||||
.load::<PersonViewSafeTuple>(conn)?;
|
||||
|
||||
|
@ -45,6 +46,7 @@ impl PersonViewSafe {
|
|||
.or(person::ban_expires.gt(now)),
|
||||
),
|
||||
)
|
||||
.filter(person::deleted.eq(false))
|
||||
.load::<PersonViewSafeTuple>(conn)?;
|
||||
|
||||
Ok(Self::from_tuple_to_vec(banned))
|
||||
|
|
Loading…
Reference in a new issue