This commit is contained in:
mdecimus
2024-08-01 17:09:39 +02:00
parent ed214fd087
commit 3cb8918d2e
34 changed files with 500 additions and 388 deletions

View File

@@ -707,7 +707,7 @@ impl ToRequestError for trc::Error {
match self.as_ref() {
trc::EventType::Jmap(cause) => match cause {
trc::JmapEvent::UnknownCapability => RequestError::unknown_capability(details),
trc::JmapEvent::NotJSON => RequestError::not_json(details),
trc::JmapEvent::NotJson => RequestError::not_json(details),
trc::JmapEvent::NotRequest => RequestError::not_request(details),
_ => RequestError::invalid_parameters(),
},

View File

@@ -418,7 +418,11 @@ impl JMAP {
};
Err(manage::unsupported(format!(
"Requested action is unsupported for {class} directories.",
concat!(
"{} directory cannot be managed. ",
"Only internal directories support inserts and update operations."
),
class
)))
}
}

View File

@@ -160,25 +160,29 @@ impl JMAP {
}
pub async fn get_access_token(&self, account_id: u32) -> trc::Result<AccessToken> {
match self
let err = match self
.core
.storage
.directory
.query(QueryBy::Id(account_id), true)
.await
{
Ok(Some(principal)) => self.update_access_token(AccessToken::new(principal)).await,
Ok(Some(principal)) => {
return self.update_access_token(AccessToken::new(principal)).await
}
Ok(None) => Err(trc::AuthEvent::Error
.into_err()
.details("Account not found.")
.caused_by(trc::location!())),
Err(err) => match &self.core.jmap.fallback_admin {
Some((_, secret)) if account_id == u32::MAX => {
self.update_access_token(AccessToken::new(Principal::fallback_admin(secret)))
.await
}
_ => Err(err),
},
Err(err) => Err(err),
};
match &self.core.jmap.fallback_admin {
Some((_, secret)) if account_id == u32::MAX => {
self.update_access_token(AccessToken::new(Principal::fallback_admin(secret)))
.await
}
_ => err,
}
}
}