2 use actix_web::web::Data;
3 use lemmy_api_common::{
5 person::{BannedPersonsResponse, GetBannedPersons},
6 utils::{is_admin, local_user_view_from_jwt},
8 use lemmy_db_views_actor::structs::PersonView;
9 use lemmy_utils::error::LemmyError;
11 #[async_trait::async_trait(?Send)]
12 impl Perform for GetBannedPersons {
13 type Response = BannedPersonsResponse;
15 async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
16 let data: &GetBannedPersons = self;
17 let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
19 // Make sure user is an admin
20 is_admin(&local_user_view)?;
22 let banned = PersonView::banned(&mut context.pool()).await?;
24 Ok(Self::Response { banned })