diff --git a/crates/api/src/local_user/add_admin.rs b/crates/api/src/local_user/add_admin.rs index adcd0c940..8e50147a4 100644 --- a/crates/api/src/local_user/add_admin.rs +++ b/crates/api/src/local_user/add_admin.rs @@ -11,6 +11,7 @@ use lemmy_db_schema::{ }, traits::Crud, }; +use lemmy_db_views::structs::LocalUserView; use lemmy_db_views_actor::structs::PersonView; use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType}; @@ -24,9 +25,14 @@ pub async fn add_admin( // Make sure user is an admin is_admin(&local_user_view)?; + // Make sure that the person_id added is local + let added_local_user = LocalUserView::read_person(&mut context.pool(), data.person_id) + .await + .with_lemmy_type(LemmyErrorType::ObjectNotLocal)?; + let added_admin = LocalUser::update( &mut context.pool(), - data.local_user_id, + added_local_user.local_user.id, &LocalUserUpdateForm { admin: Some(data.added), ..Default::default() diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs index 45574d0f2..8d58ebf68 100644 --- a/crates/api_common/src/person.rs +++ b/crates/api_common/src/person.rs @@ -1,6 +1,6 @@ use crate::sensitive::Sensitive; use lemmy_db_schema::{ - newtypes::{CommentReplyId, CommunityId, LanguageId, LocalUserId, PersonId, PersonMentionId}, + newtypes::{CommentReplyId, CommunityId, LanguageId, PersonId, PersonMentionId}, CommentSortType, ListingType, SortType, @@ -198,7 +198,7 @@ pub struct MarkAllAsRead { #[cfg_attr(feature = "full", ts(export))] /// Adds an admin to a site. pub struct AddAdmin { - pub local_user_id: LocalUserId, + pub person_id: PersonId, pub added: bool, pub auth: Sensitive, }