mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 20:31:19 +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,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
|
use lemmy_db_views::structs::LocalUserView;
|
||||||
use lemmy_db_views_actor::structs::PersonView;
|
use lemmy_db_views_actor::structs::PersonView;
|
||||||
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
|
||||||
|
|
||||||
|
@ -24,9 +25,14 @@ pub async fn add_admin(
|
||||||
// Make sure user is an admin
|
// Make sure user is an admin
|
||||||
is_admin(&local_user_view)?;
|
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(
|
let added_admin = LocalUser::update(
|
||||||
&mut context.pool(),
|
&mut context.pool(),
|
||||||
data.local_user_id,
|
added_local_user.local_user.id,
|
||||||
&LocalUserUpdateForm {
|
&LocalUserUpdateForm {
|
||||||
admin: Some(data.added),
|
admin: Some(data.added),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::sensitive::Sensitive;
|
use crate::sensitive::Sensitive;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
newtypes::{CommentReplyId, CommunityId, LanguageId, LocalUserId, PersonId, PersonMentionId},
|
newtypes::{CommentReplyId, CommunityId, LanguageId, PersonId, PersonMentionId},
|
||||||
CommentSortType,
|
CommentSortType,
|
||||||
ListingType,
|
ListingType,
|
||||||
SortType,
|
SortType,
|
||||||
|
@ -198,7 +198,7 @@ pub struct MarkAllAsRead {
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
#[cfg_attr(feature = "full", ts(export))]
|
||||||
/// Adds an admin to a site.
|
/// Adds an admin to a site.
|
||||||
pub struct AddAdmin {
|
pub struct AddAdmin {
|
||||||
pub local_user_id: LocalUserId,
|
pub person_id: PersonId,
|
||||||
pub added: bool,
|
pub added: bool,
|
||||||
pub auth: Sensitive<String>,
|
pub auth: Sensitive<String>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue