summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2019-10-13 17:36:35 -0700
committerDessalines <tyhou13@gmx.com>2019-10-13 17:36:35 -0700
commit663a601e1102794416ebc00af3c5479a0153518b (patch)
tree575ed7b4f023682a00add021ff3dedab6d3330f9 /server
parent2520f3a0066f85afd287c55c8949c87047eaad47 (diff)
Adding admin abilities on user pages.
- Fixes #280
Diffstat (limited to 'server')
-rw-r--r--server/src/api/user.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/server/src/api/user.rs b/server/src/api/user.rs
index 222b6408..aded8557 100644
--- a/server/src/api/user.rs
+++ b/server/src/api/user.rs
@@ -50,6 +50,7 @@ pub struct GetUserDetailsResponse {
moderates: Vec<CommunityModeratorView>,
comments: Vec<CommentView>,
posts: Vec<PostView>,
+ admins: Vec<UserView>,
}
#[derive(Serialize, Deserialize)]
@@ -367,6 +368,11 @@ impl Perform<GetUserDetailsResponse> for Oper<GetUserDetails> {
let follows = CommunityFollowerView::for_user(&conn, user_details_id)?;
let moderates = CommunityModeratorView::for_user(&conn, user_details_id)?;
+ let site_creator_id = Site::read(&conn, 1)?.creator_id;
+ let mut admins = UserView::admins(&conn)?;
+ let creator_index = admins.iter().position(|r| r.id == site_creator_id).unwrap();
+ let creator_user = admins.remove(creator_index);
+ admins.insert(0, creator_user);
// Return the jwt
Ok(GetUserDetailsResponse {
@@ -376,6 +382,7 @@ impl Perform<GetUserDetailsResponse> for Oper<GetUserDetails> {
moderates: moderates,
comments: comments,
posts: posts,
+ admins: admins,
})
}
}