2022-04-13 18:12:25 +00:00
|
|
|
use crate::Perform;
|
|
|
|
use actix_web::web::Data;
|
|
|
|
use lemmy_api_common::{
|
2022-11-28 14:29:33 +00:00
|
|
|
context::LemmyContext,
|
2022-04-13 18:12:25 +00:00
|
|
|
person::{BannedPersonsResponse, GetBannedPersons},
|
2022-11-09 10:05:00 +00:00
|
|
|
utils::{get_local_user_view_from_jwt, is_admin},
|
2022-04-13 18:12:25 +00:00
|
|
|
};
|
2023-03-01 17:19:46 +00:00
|
|
|
use lemmy_db_views_actor::structs::PersonView;
|
2022-06-02 14:33:41 +00:00
|
|
|
use lemmy_utils::{error::LemmyError, ConnectionId};
|
2022-04-13 18:12:25 +00:00
|
|
|
|
|
|
|
#[async_trait::async_trait(?Send)]
|
|
|
|
impl Perform for GetBannedPersons {
|
|
|
|
type Response = BannedPersonsResponse;
|
|
|
|
|
|
|
|
async fn perform(
|
|
|
|
&self,
|
|
|
|
context: &Data<LemmyContext>,
|
|
|
|
_websocket_id: Option<ConnectionId>,
|
|
|
|
) -> Result<Self::Response, LemmyError> {
|
|
|
|
let data: &GetBannedPersons = self;
|
|
|
|
let local_user_view =
|
|
|
|
get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
|
|
|
|
|
|
|
|
// Make sure user is an admin
|
|
|
|
is_admin(&local_user_view)?;
|
|
|
|
|
2023-03-01 17:19:46 +00:00
|
|
|
let banned = PersonView::banned(context.pool()).await?;
|
2022-04-13 18:12:25 +00:00
|
|
|
|
|
|
|
let res = Self::Response { banned };
|
|
|
|
|
|
|
|
Ok(res)
|
|
|
|
}
|
|
|
|
}
|