presence: Wire up stanza_error.

This commit is contained in:
Emmanuel Gil Peyrot 2017-05-01 01:02:35 +01:00
parent 2465885975
commit 3dd0eb3a9b

View file

@ -16,6 +16,7 @@ use error::Error;
use ns;
use stanza_error;
use delay;
use ecaps2;
@ -50,6 +51,7 @@ pub enum PresencePayload {
Show(Show),
Status(Status),
Priority(Priority),
StanzaError(stanza_error::StanzaError),
Delay(delay::Delay),
ECaps2(ecaps2::ECaps2),
}
@ -177,7 +179,9 @@ pub fn parse_presence(root: &Element) -> Result<Presence, Error> {
}
priority = Some(Priority::from_str(elem.text().as_ref())?);
} else {
let payload = if let Ok(delay) = delay::parse_delay(elem) {
let payload = if let Ok(stanza_error) = stanza_error::parse_stanza_error(elem) {
Some(PresencePayload::StanzaError(stanza_error))
} else if let Ok(delay) = delay::parse_delay(elem) {
Some(PresencePayload::Delay(delay))
} else if let Ok(ecaps2) = ecaps2::parse_ecaps2(elem) {
Some(PresencePayload::ECaps2(ecaps2))
@ -222,6 +226,7 @@ pub fn serialise_payload(payload: &PresencePayload) -> Element {
.append(format!("{}", priority))
.build()
},
PresencePayload::StanzaError(ref stanza_error) => stanza_error::serialise(stanza_error),
PresencePayload::Delay(ref delay) => delay::serialise(delay),
PresencePayload::ECaps2(ref ecaps2) => ecaps2::serialise(ecaps2),
}