2 use actix_web::web::Data;
3 use lemmy_api_common::{
5 get_local_user_view_from_jwt,
7 person::{BannedPersonsResponse, GetBannedPersons},
9 use lemmy_db_views_actor::person_view::PersonViewSafe;
10 use lemmy_utils::{ConnectionId, LemmyError};
11 use lemmy_websocket::LemmyContext;
13 #[async_trait::async_trait(?Send)]
14 impl Perform for GetBannedPersons {
15 type Response = BannedPersonsResponse;
19 context: &Data<LemmyContext>,
20 _websocket_id: Option<ConnectionId>,
21 ) -> Result<Self::Response, LemmyError> {
22 let data: &GetBannedPersons = self;
24 get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
26 // Make sure user is an admin
27 is_admin(&local_user_view)?;
29 let banned = blocking(context.pool(), PersonViewSafe::banned).await??;
31 let res = Self::Response { banned };