Add moderates to MyUserInfo

This commit is contained in:
Dessalines 2021-08-10 20:14:21 -04:00
parent a900cec1bf
commit 32062ecfab
2 changed files with 10 additions and 0 deletions

View file

@ -8,6 +8,7 @@ use lemmy_db_views::{
use lemmy_db_views_actor::{ use lemmy_db_views_actor::{
community_block_view::CommunityBlockView, community_block_view::CommunityBlockView,
community_follower_view::CommunityFollowerView, community_follower_view::CommunityFollowerView,
community_moderator_view::CommunityModeratorView,
community_view::CommunityView, community_view::CommunityView,
person_block_view::PersonBlockView, person_block_view::PersonBlockView,
person_view::PersonViewSafe, person_view::PersonViewSafe,
@ -124,6 +125,7 @@ pub struct GetSiteResponse {
pub struct MyUserInfo { pub struct MyUserInfo {
pub local_user_view: LocalUserSettingsView, pub local_user_view: LocalUserSettingsView,
pub follows: Vec<CommunityFollowerView>, pub follows: Vec<CommunityFollowerView>,
pub moderates: Vec<CommunityModeratorView>,
pub community_blocks: Vec<CommunityBlockView>, pub community_blocks: Vec<CommunityBlockView>,
pub person_blocks: Vec<PersonBlockView>, pub person_blocks: Vec<PersonBlockView>,
} }

View file

@ -11,6 +11,7 @@ use lemmy_db_views::site_view::SiteView;
use lemmy_db_views_actor::{ use lemmy_db_views_actor::{
community_block_view::CommunityBlockView, community_block_view::CommunityBlockView,
community_follower_view::CommunityFollowerView, community_follower_view::CommunityFollowerView,
community_moderator_view::CommunityModeratorView,
person_block_view::PersonBlockView, person_block_view::PersonBlockView,
person_view::PersonViewSafe, person_view::PersonViewSafe,
}; };
@ -113,9 +114,16 @@ impl PerformCrud for GetSite {
.await? .await?
.map_err(|_| ApiError::err("system_err_login"))?; .map_err(|_| ApiError::err("system_err_login"))?;
let moderates = blocking(context.pool(), move |conn| {
CommunityModeratorView::for_person(conn, person_id)
})
.await?
.map_err(|_| ApiError::err("system_err_login"))?;
Some(MyUserInfo { Some(MyUserInfo {
local_user_view, local_user_view,
follows, follows,
moderates,
community_blocks, community_blocks,
person_blocks, person_blocks,
}) })