From 32062ecfab85ef418c697424d8f2014ad93efeda Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 10 Aug 2021 20:14:21 -0400 Subject: [PATCH] Add moderates to MyUserInfo --- crates/api_common/src/site.rs | 2 ++ crates/api_crud/src/site/read.rs | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/crates/api_common/src/site.rs b/crates/api_common/src/site.rs index d2a94a681..af63854d3 100644 --- a/crates/api_common/src/site.rs +++ b/crates/api_common/src/site.rs @@ -8,6 +8,7 @@ use lemmy_db_views::{ use lemmy_db_views_actor::{ community_block_view::CommunityBlockView, community_follower_view::CommunityFollowerView, + community_moderator_view::CommunityModeratorView, community_view::CommunityView, person_block_view::PersonBlockView, person_view::PersonViewSafe, @@ -124,6 +125,7 @@ pub struct GetSiteResponse { pub struct MyUserInfo { pub local_user_view: LocalUserSettingsView, pub follows: Vec, + pub moderates: Vec, pub community_blocks: Vec, pub person_blocks: Vec, } diff --git a/crates/api_crud/src/site/read.rs b/crates/api_crud/src/site/read.rs index 73d1ddfc9..cfbaf07a5 100644 --- a/crates/api_crud/src/site/read.rs +++ b/crates/api_crud/src/site/read.rs @@ -11,6 +11,7 @@ use lemmy_db_views::site_view::SiteView; use lemmy_db_views_actor::{ community_block_view::CommunityBlockView, community_follower_view::CommunityFollowerView, + community_moderator_view::CommunityModeratorView, person_block_view::PersonBlockView, person_view::PersonViewSafe, }; @@ -113,9 +114,16 @@ impl PerformCrud for GetSite { .await? .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 { local_user_view, follows, + moderates, community_blocks, person_blocks, })