do_websocket_operation::<ApproveRegistrationApplication>(context, id, op, data).await
}
UserOperation::BanPerson => do_websocket_operation::<BanPerson>(context, id, op, data).await,
+ UserOperation::GetBannedPersons => {
+ do_websocket_operation::<GetBannedPersons>(context, id, op, data).await
+ }
UserOperation::BlockPerson => {
do_websocket_operation::<BlockPerson>(context, id, op, data).await
}
}
}
+#[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)?;
+
+ let banned = blocking(context.pool(), PersonViewSafe::banned).await??;
+
+ let res = Self::Response { banned };
+
+ Ok(res)
+ }
+}
+
#[async_trait::async_trait(?Send)]
impl Perform for BlockPerson {
type Response = BlockPersonResponse;
let creator_person = admins.remove(creator_index);
admins.insert(0, creator_person);
- let banned = blocking(context.pool(), PersonViewSafe::banned).await??;
let federated_instances = build_federated_instances(
context.pool(),
&context.settings().federation,
Ok(GetSiteResponse {
site_view: Some(site_view),
admins,
- banned,
online: 0,
version: version::VERSION.to_string(),
my_user: None,
pub auth: Sensitive<String>,
}
+#[derive(Debug, Serialize, Deserialize)]
+pub struct GetBannedPersons {
+ pub auth: String,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct BannedPersonsResponse {
+ pub banned: Vec<PersonViewSafe>,
+}
+
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct BanPersonResponse {
pub person_view: PersonViewSafe,
pub struct GetSiteResponse {
pub site_view: Option<SiteView>, // Because the site might not be set up yet
pub admins: Vec<PersonViewSafe>,
- pub banned: Vec<PersonViewSafe>,
pub online: usize,
pub version: String,
pub my_user: Option<MyUserInfo>,
}
}
- let banned = blocking(context.pool(), PersonViewSafe::banned).await??;
-
let online = context
.chat_server()
.send(GetUsersOnline)
Ok(GetSiteResponse {
site_view,
admins,
- banned,
online,
version: version::VERSION.to_string(),
my_user,
ListRegistrationApplications,
ApproveRegistrationApplication,
BanPerson,
+ GetBannedPersons,
Search,
ResolveObject,
MarkAllAsRead,
.route("/join", web::post().to(route_post::<UserJoin>))
// Admin action. I don't like that it's in /user
.route("/ban", web::post().to(route_post::<BanPerson>))
+ .route("/banned", web::get().to(route_get::<GetBannedPersons>))
.route("/block", web::post().to(route_post::<BlockPerson>))
// Account actions. I don't like that they're in /user maybe /accounts
.route("/login", web::post().to(route_post::<Login>))