Merge branch 'fix-1-add-ask' into 'master'
Add ask attribute from RFC3921. Closes #1 See merge request xmpp-rs/xmpp-parsers!4
This commit is contained in:
commit
69f77e9cf5
1 changed files with 32 additions and 2 deletions
|
@ -36,6 +36,14 @@ generate_attribute!(
|
||||||
}, Default = None
|
}, Default = None
|
||||||
);
|
);
|
||||||
|
|
||||||
|
generate_attribute!(
|
||||||
|
/// The sub-state of subscription with a contact.
|
||||||
|
Ask, "ask", {
|
||||||
|
/// Pending sub-state of the 'none' subscription state
|
||||||
|
Subscribe => "subscribe",
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Contact from the user’s contact list.
|
/// Contact from the user’s contact list.
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
|
@ -48,7 +56,10 @@ generate_element!(
|
||||||
name: Option<String> = "name" => optional_empty,
|
name: Option<String> = "name" => optional_empty,
|
||||||
|
|
||||||
/// Subscription status of this contact.
|
/// Subscription status of this contact.
|
||||||
subscription: Subscription = "subscription" => default
|
subscription: Subscription = "subscription" => default,
|
||||||
|
|
||||||
|
///
|
||||||
|
ask: Option<Ask> = "ask" => optional_empty
|
||||||
],
|
],
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
|
@ -144,23 +155,42 @@ mod tests {
|
||||||
<item jid='benvolio@example.net'
|
<item jid='benvolio@example.net'
|
||||||
name='Benvolio'
|
name='Benvolio'
|
||||||
subscription='both'/>
|
subscription='both'/>
|
||||||
|
<item jid='contact@example.org'
|
||||||
|
subscription='none'
|
||||||
|
ask='subscribe'
|
||||||
|
name='MyContact'>
|
||||||
|
<group>MyBuddies</group>
|
||||||
|
</item>
|
||||||
</query>
|
</query>
|
||||||
"#
|
"#
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let roster = Roster::try_from(elem).unwrap();
|
let roster = Roster::try_from(elem).unwrap();
|
||||||
assert_eq!(roster.ver, Some(String::from("ver11")));
|
assert_eq!(roster.ver, Some(String::from("ver11")));
|
||||||
assert_eq!(roster.items.len(), 3);
|
assert_eq!(roster.items.len(), 4);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
roster.items[0].jid,
|
roster.items[0].jid,
|
||||||
Jid::from_str("romeo@example.net").unwrap()
|
Jid::from_str("romeo@example.net").unwrap()
|
||||||
);
|
);
|
||||||
assert_eq!(roster.items[0].name, Some(String::from("Romeo")));
|
assert_eq!(roster.items[0].name, Some(String::from("Romeo")));
|
||||||
assert_eq!(roster.items[0].subscription, Subscription::Both);
|
assert_eq!(roster.items[0].subscription, Subscription::Both);
|
||||||
|
assert_eq!(roster.items[0].ask, None);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
roster.items[0].groups,
|
roster.items[0].groups,
|
||||||
vec!(Group::from_str("Friends").unwrap())
|
vec!(Group::from_str("Friends").unwrap())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
roster.items[3].jid,
|
||||||
|
Jid::from_str("contact@example.org").unwrap()
|
||||||
|
);
|
||||||
|
assert_eq!(roster.items[3].name, Some(String::from("MyContact")));
|
||||||
|
assert_eq!(roster.items[3].subscription, Subscription::None);
|
||||||
|
assert_eq!(roster.items[3].ask, Some(Ask::Subscribe));
|
||||||
|
assert_eq!(
|
||||||
|
roster.items[3].groups,
|
||||||
|
vec!(Group::from_str("MyBuddies").unwrap())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue