xmpp-parsers: Support required in SM feature
This was forgotten in 0f0759b207.
That element is only specified in the XML schema, its semantics aren’t
defined anywhere, but we can guess them anyway.
This commit is contained in:
parent
74f67b9585
commit
4e0cd5d96b
3 changed files with 19 additions and 6 deletions
|
|
@ -108,7 +108,8 @@ XXXX-YY-ZZ RELEASER <admin@example.com>
|
|||
- Push Notifications (XEP-0357) (!543)
|
||||
- JSON Containers (XEP-0335) (!546)
|
||||
* Improvements:
|
||||
- Add support for `<optional/> in XEP-0198 feature advertisment
|
||||
- Add support for `<optional/>` and `<required/>` in XEP-0198 feature
|
||||
advertisment.
|
||||
- Add support application-specific error conditions in XEP-0198
|
||||
- Keep unsupported vCard elements as `minidom::Element`, so that they
|
||||
get serialized back instead of being dropped. We now also test for
|
||||
|
|
|
|||
|
|
@ -269,7 +269,13 @@ mod tests {
|
|||
|
||||
let inline = auth.inline.unwrap();
|
||||
assert_eq!(inline.bind2.unwrap().inline_features.len(), 0);
|
||||
assert_eq!(inline.sm.unwrap(), StreamManagement { optional: false });
|
||||
assert_eq!(
|
||||
inline.sm.unwrap(),
|
||||
StreamManagement {
|
||||
optional: false,
|
||||
required: false
|
||||
}
|
||||
);
|
||||
assert_eq!(inline.payloads.len(), 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ pub struct Resumed {
|
|||
pub previd: StreamId,
|
||||
}
|
||||
|
||||
// TODO: add support for optional and required.
|
||||
// TODO: Only allow either optional or required, not both.
|
||||
/// Represents availability of Stream Management in `<stream:features/>`.
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::SM, name = "sm")]
|
||||
|
|
@ -141,6 +141,10 @@ pub struct StreamManagement {
|
|||
/// `<optional/>` flag.
|
||||
#[xml(flag)]
|
||||
pub optional: bool,
|
||||
|
||||
/// `<required/>` flag.
|
||||
#[xml(flag)]
|
||||
pub required: bool,
|
||||
}
|
||||
|
||||
/// Application-specific error condition to use when the peer acknowledges
|
||||
|
|
@ -222,7 +226,7 @@ mod tests {
|
|||
assert_size!(R, 0);
|
||||
assert_size!(Resume, 16);
|
||||
assert_size!(Resumed, 16);
|
||||
assert_size!(StreamManagement, 1);
|
||||
assert_size!(StreamManagement, 2);
|
||||
assert_size!(HandledCountTooHigh, 8);
|
||||
}
|
||||
|
||||
|
|
@ -237,7 +241,7 @@ mod tests {
|
|||
assert_size!(R, 0);
|
||||
assert_size!(Resume, 32);
|
||||
assert_size!(Resumed, 32);
|
||||
assert_size!(StreamManagement, 1);
|
||||
assert_size!(StreamManagement, 2);
|
||||
assert_size!(HandledCountTooHigh, 8);
|
||||
}
|
||||
|
||||
|
|
@ -251,7 +255,9 @@ mod tests {
|
|||
#[test]
|
||||
fn stream_feature() {
|
||||
let elem: Element = "<sm xmlns='urn:xmpp:sm:3'/>".parse().unwrap();
|
||||
StreamManagement::try_from(elem).unwrap();
|
||||
let sm = StreamManagement::try_from(elem).unwrap();
|
||||
assert_eq!(sm.optional, false);
|
||||
assert_eq!(sm.required, false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue