mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 03:11:32 +00:00
Change AddAdmin to use person_id instead of local_user_id (#3941)
- Front ends don't have easy access to local_user_id on moddable items like comments and posts.
This commit is contained in:
parent
a0ea8dbc00
commit
797d26fdf4
2 changed files with 9 additions and 3 deletions
|
@ -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()
|
||||
|
|
|
@ -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<String>,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue