Adding multi_communities_created to PersonDetails, and multi_community_follows to MyUserInfo (#6132)

* Adding multi_community_name to list_posts.

- This is necessary for front ends to not have to pre-fetch the
multi-community.id
- Works the same way as community_name.

* Upgrading to debian:sid to fix local docker issues.

* Adding multi_communities_created to PersonDetails, and followed to MyUserInfo.
This commit is contained in:
Dessalines
2025-11-07 17:11:32 +08:00
committed by GitHub
parent 6c062e50fc
commit 4e7a306acc
9 changed files with 35 additions and 2 deletions

2
Cargo.lock generated
View File

@@ -3999,6 +3999,7 @@ dependencies = [
"i-love-jesus",
"lemmy_db_schema 1.0.0-alpha.12",
"lemmy_db_schema_file",
"lemmy_db_views_community",
"lemmy_db_views_community_moderator",
"lemmy_utils 1.0.0-alpha.12",
"pretty_assertions",
@@ -4189,6 +4190,7 @@ dependencies = [
"i-love-jesus",
"lemmy_db_schema 1.0.0-alpha.12",
"lemmy_db_schema_file",
"lemmy_db_views_community",
"lemmy_db_views_community_follower",
"lemmy_db_views_community_moderator",
"lemmy_db_views_local_user",

View File

@@ -5,6 +5,7 @@ use lemmy_api_utils::{
context::LemmyContext,
utils::{check_private_instance, is_admin, read_site_for_actor},
};
use lemmy_db_views_community::MultiCommunityView;
use lemmy_db_views_community_moderator::CommunityModeratorView;
use lemmy_db_views_local_user::LocalUserView;
use lemmy_db_views_person::{
@@ -44,6 +45,7 @@ pub async fn read_person(
is_admin,
)
.await?;
let moderates = CommunityModeratorView::for_person(
&mut context.pool(),
person_details_id,
@@ -51,11 +53,20 @@ pub async fn read_person(
)
.await?;
let multi_communities_created = MultiCommunityView::list(
&mut context.pool(),
Some(person_details_id),
my_person_id,
false,
)
.await?;
let site = read_site_for_actor(person_view.person.ap_id.clone(), &context).await?;
Ok(Json(GetPersonDetailsResponse {
person_view,
site,
moderates,
multi_communities_created,
}))
}

View File

@@ -10,6 +10,7 @@ use lemmy_db_schema::{
},
traits::Blockable,
};
use lemmy_db_views_community::MultiCommunityView;
use lemmy_db_views_community_follower::CommunityFollowerView;
use lemmy_db_views_community_moderator::CommunityModeratorView;
use lemmy_db_views_local_user::LocalUserView;
@@ -34,6 +35,7 @@ pub async fn get_my_user(
instance_persons_blocks,
person_blocks,
moderates,
multi_community_follows,
keyword_blocks,
discussion_languages,
) = lemmy_db_schema::try_join_with_pool!(pool => (
@@ -43,6 +45,12 @@ pub async fn get_my_user(
|pool| InstanceActions::read_persons_block_for_person(pool, person_id),
|pool| PersonActions::read_blocks_for_person(pool, person_id),
|pool| CommunityModeratorView::for_person(pool, person_id, Some(&local_user_view.local_user)),
|pool| MultiCommunityView::list(
pool,
None,
Some(person_id),
true,
),
|pool| LocalUserKeywordBlock::read(pool, local_user_id),
|pool| LocalUserLanguage::read(pool, local_user_id)
))?;
@@ -51,6 +59,7 @@ pub async fn get_my_user(
local_user_view: local_user_view.clone(),
follows,
moderates,
multi_community_follows,
community_blocks,
instance_communities_blocks,
instance_persons_blocks,

View File

@@ -470,6 +470,7 @@ async fn list_posts_v3(
community_id: community_id.map(|id| CommunityId(id.0)),
community_name,
multi_community_id: None,
multi_community_name: None,
show_hidden,
show_read,
show_nsfw,

View File

@@ -24,11 +24,13 @@ full = [
"lemmy_db_schema/full",
"lemmy_db_schema_file/full",
"lemmy_db_views_community_moderator/full",
"lemmy_db_views_community/full",
]
ts-rs = [
"dep:ts-rs",
"lemmy_db_schema/ts-rs",
"lemmy_db_views_community_moderator/ts-rs",
"lemmy_db_views_community/ts-rs",
]
[dependencies]
@@ -36,6 +38,7 @@ lemmy_db_schema = { workspace = true }
lemmy_utils = { workspace = true, optional = true }
lemmy_db_schema_file = { workspace = true }
lemmy_db_views_community_moderator = { workspace = true }
lemmy_db_views_community = { workspace = true }
diesel = { workspace = true, optional = true }
diesel-async = { workspace = true, optional = true }
serde = { workspace = true }

View File

@@ -1,5 +1,6 @@
use crate::PersonView;
use lemmy_db_schema::{newtypes::PersonId, source::site::Site};
use lemmy_db_views_community::MultiCommunityView;
use lemmy_db_views_community_moderator::CommunityModeratorView;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
@@ -78,6 +79,7 @@ pub struct GetPersonDetailsResponse {
pub person_view: PersonView,
pub site: Option<Site>,
pub moderates: Vec<CommunityModeratorView>,
pub multi_communities_created: Vec<MultiCommunityView>,
}
#[skip_serializing_none]

View File

@@ -23,6 +23,7 @@ full = [
"lemmy_db_schema/full",
"lemmy_db_schema_file/full",
"lemmy_db_views_person/full",
"lemmy_db_views_community/full",
"extism",
"extism-convert",
"anyhow",
@@ -36,6 +37,7 @@ ts-rs = [
"lemmy_db_views_community_moderator/ts-rs",
"lemmy_db_views_local_user/ts-rs",
"lemmy_db_views_person/ts-rs",
"lemmy_db_views_community/ts-rs",
]
[dependencies]
@@ -46,6 +48,7 @@ lemmy_db_views_community_follower = { workspace = true }
lemmy_db_views_community_moderator = { workspace = true }
lemmy_db_views_local_user = { workspace = true }
lemmy_db_views_person = { workspace = true }
lemmy_db_views_community = { workspace = true }
diesel = { workspace = true, optional = true }
diesel-async = { workspace = true, optional = true }
serde = { workspace = true }

View File

@@ -33,6 +33,7 @@ use lemmy_db_schema_file::enums::{
RegistrationMode,
VoteShow,
};
use lemmy_db_views_community::MultiCommunityView;
use lemmy_db_views_community_follower::CommunityFollowerView;
use lemmy_db_views_community_moderator::CommunityModeratorView;
use lemmy_db_views_local_user::LocalUserView;
@@ -462,6 +463,7 @@ pub struct MyUserInfo {
pub local_user_view: LocalUserView,
pub follows: Vec<CommunityFollowerView>,
pub moderates: Vec<CommunityModeratorView>,
pub multi_community_follows: Vec<MultiCommunityView>,
pub community_blocks: Vec<Community>,
pub instance_communities_blocks: Vec<Instance>,
pub instance_persons_blocks: Vec<Instance>,

View File

@@ -7,8 +7,8 @@ ARG AMD_BUILDER_IMAGE=rust:${RUST_VERSION}
# Repo: https://github.com/raskyld/lemmy-cross-toolchains
ARG ARM_BUILDER_IMAGE="ghcr.io/raskyld/aarch64-lemmy-linux-gnu:v0.5.0"
ARG AMD_RUNNER_IMAGE=debian:bookworm-slim
ARG ARM_RUNNER_IMAGE=debian:bookworm-slim
ARG AMD_RUNNER_IMAGE=debian:sid-slim
ARG ARM_RUNNER_IMAGE=debian:sid-slim
ARG UNAME=lemmy
ARG UID=1000