MCPcopy Create free account
hub / github.com/dfinity/orbit / can_deploy_station

Method can_deploy_station

core/control-panel/impl/src/services/user.rs:165–191  ·  view source on GitHub ↗

Checks if a user can deploy a station.

(&self, ctx: &CallContext)

Source from the content-addressed store, hash-verified

163
164 /// Checks if a user can deploy a station.
165 pub fn can_deploy_station(&self, ctx: &CallContext) -> ServiceResult<CanDeployStation> {
166 let user = self.get_user_by_identity(&ctx.caller(), ctx)?;
167 let config = canister_config().ok_or(DeployError::Failed {
168 reason: "Canister config not initialized.".to_string(),
169 })?;
170
171 let allowed_globally = match config.global_rate_limiter.can_deploy_station() {
172 CanDeployStation::Allowed(remaining) => remaining,
173 CanDeployStation::QuotaExceeded => return Ok(CanDeployStation::QuotaExceeded),
174 CanDeployStation::NotAllowed(subscription_status) => {
175 return Ok(CanDeployStation::NotAllowed(subscription_status))
176 }
177 };
178
179 let allowed_per_user = match user.can_deploy_station() {
180 CanDeployStation::Allowed(remaining) => remaining,
181 CanDeployStation::QuotaExceeded => return Ok(CanDeployStation::QuotaExceeded),
182 CanDeployStation::NotAllowed(subscription_status) => {
183 return Ok(CanDeployStation::NotAllowed(subscription_status))
184 }
185 };
186
187 Ok(CanDeployStation::Allowed(std::cmp::min(
188 allowed_globally,
189 allowed_per_user,
190 )))
191 }
192
193 /// Checks if the caller has access to the given user.
194 ///

Callers 1

deploy_stationMethod · 0.45

Calls 3

canister_configFunction · 0.85
get_user_by_identityMethod · 0.45
callerMethod · 0.45

Tested by

no test coverage detected