use crate::authorization::permissions::Permission; use api::auth_capnp::response::successful::Builder; use crate::capnp::machinesystem::Machines; use crate::capnp::permissionsystem::Permissions; use crate::capnp::user_system::Users; use crate::session::SessionHandle; #[derive(Debug, Clone)] pub struct APISession; impl APISession { pub fn new() -> Self { Self } pub fn build(session: SessionHandle, builder: Builder) { let mut builder = builder.init_session(); builder.reborrow().set_resources(capnp_rpc::new_client(Machines::new(session.clone()))); if session.has_perm(Permission::new("bffh.users.manage")) { let u = Users::new(session.clone()); builder.reborrow().set_users(capnp_rpc::new_client(u.clone())); } builder.set_permissions(capnp_rpc::new_client(Permissions::new(session))); } }