aboutsummaryrefslogtreecommitdiffstats
path: root/stanza
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2025-03-27 14:26:27 +0000
committerLibravatar cel 🌸 <cel@bunny.garden>2025-03-27 14:26:27 +0000
commite703284539384b461d204c73e7e14daead3f06d9 (patch)
tree3a49a5ed8b41e78a45dce91ad7723f4d6ebab26d /stanza
parent8c239e5c7a49cff350104b09cbb74d862c2ec420 (diff)
downloadluz-e703284539384b461d204c73e7e14daead3f06d9.tar.gz
luz-e703284539384b461d204c73e7e14daead3f06d9.tar.bz2
luz-e703284539384b461d204c73e7e14daead3f06d9.zip
feat: disco info from server
Diffstat (limited to 'stanza')
-rw-r--r--stanza/src/client/error.rs38
-rw-r--r--stanza/src/xep_0030/info.rs6
2 files changed, 41 insertions, 3 deletions
diff --git a/stanza/src/client/error.rs b/stanza/src/client/error.rs
index aa142bf..33bc85e 100644
--- a/stanza/src/client/error.rs
+++ b/stanza/src/client/error.rs
@@ -99,3 +99,41 @@ impl FromStr for ErrorType {
}
}
}
+
+impl From<StanzaError> for Error {
+ fn from(value: StanzaError) -> Self {
+ let error_type = match value {
+ StanzaError::BadRequest => ErrorType::Modify,
+ StanzaError::Conflict => ErrorType::Cancel,
+ // cancel or modify
+ StanzaError::FeatureNotImplemented => ErrorType::Cancel,
+ StanzaError::Forbidden => ErrorType::Auth,
+ StanzaError::Gone(_) => ErrorType::Cancel,
+ StanzaError::InternalServerError => ErrorType::Cancel,
+ StanzaError::ItemNotFound => ErrorType::Cancel,
+ StanzaError::JIDMalformed => ErrorType::Modify,
+ StanzaError::NotAcceptable => ErrorType::Modify,
+ StanzaError::NotAllowed => ErrorType::Cancel,
+ StanzaError::NotAuthorized => ErrorType::Auth,
+ // modify or wait
+ StanzaError::PolicyViolation => ErrorType::Modify,
+ StanzaError::RecipientUnavailable => ErrorType::Wait,
+ StanzaError::Redirect(_) => ErrorType::Modify,
+ StanzaError::RegistrationRequired => ErrorType::Auth,
+ StanzaError::RemoteServerNotFound => ErrorType::Cancel,
+ StanzaError::RemoteServerTimeout => ErrorType::Wait,
+ StanzaError::ResourceConstraint => ErrorType::Wait,
+ StanzaError::ServiceUnavailable => ErrorType::Cancel,
+ StanzaError::SubscriptionRequired => ErrorType::Auth,
+ StanzaError::UndefinedCondition => ErrorType::Cancel,
+ // wait or modify
+ StanzaError::UnexpectedRequest => ErrorType::Modify,
+ };
+ Self {
+ by: None,
+ r#type: error_type,
+ error: value,
+ text: None,
+ }
+ }
+}
diff --git a/stanza/src/xep_0030/info.rs b/stanza/src/xep_0030/info.rs
index cec2dcb..589fd08 100644
--- a/stanza/src/xep_0030/info.rs
+++ b/stanza/src/xep_0030/info.rs
@@ -7,9 +7,9 @@ pub const XMLNS: &str = "http://jabber.org/protocol/disco#info";
#[derive(Debug, Clone)]
pub struct Query {
- node: Option<String>,
- features: Vec<Feature>,
- identities: Vec<Identity>,
+ pub node: Option<String>,
+ pub features: Vec<Feature>,
+ pub identities: Vec<Identity>,
}
impl FromElement for Query {