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, ConnectionId};
11 #[async_trait::async_trait(?Send)]
12 impl Perform for GetBannedPersons {
13 type Response = BannedPersonsResponse;
17 context: &Data<LemmyContext>,
18 _websocket_id: Option<ConnectionId>,
19 ) -> Result<Self::Response, LemmyError> {
20 let data: &GetBannedPersons = self;
21 let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
23 // Make sure user is an admin
24 is_admin(&local_user_view)?;
26 let banned = PersonView::banned(context.pool()).await?;
28 let res = Self::Response { banned };