2 use actix_web::web::Data;
3 use lemmy_api_common::{
4 person::{BannedPersonsResponse, GetBannedPersons},
5 utils::{blocking, get_local_user_view_from_jwt, is_admin},
7 use lemmy_db_views_actor::structs::PersonViewSafe;
8 use lemmy_utils::{error::LemmyError, ConnectionId};
9 use lemmy_websocket::LemmyContext;
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;
22 get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
24 // Make sure user is an admin
25 is_admin(&local_user_view)?;
27 let banned = blocking(context.pool(), PersonViewSafe::banned).await??;
29 let res = Self::Response { banned };