muc::user::Item Use parsers' new helpers
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
6f7f55a72f
commit
27a0e1523d
4 changed files with 45 additions and 74 deletions
|
@ -24,7 +24,7 @@ use std::ops::ControlFlow;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use xmpp_parsers::{
|
use xmpp_parsers::{
|
||||||
muc::{
|
muc::{
|
||||||
user::{Affiliation, Item as MucItem, Reason, Role, Status as MucStatus},
|
user::{Affiliation, Item as MucItem, Role, Status as MucStatus},
|
||||||
Muc, MucUser,
|
Muc, MucUser,
|
||||||
},
|
},
|
||||||
presence::{Presence, Type as PresenceType},
|
presence::{Presence, Type as PresenceType},
|
||||||
|
@ -116,10 +116,8 @@ async fn handle_presence_full_available<C: ComponentTrait>(
|
||||||
MucStatus::ServiceErrorKick,
|
MucStatus::ServiceErrorKick,
|
||||||
],
|
],
|
||||||
items: {
|
items: {
|
||||||
let mut item = MucItem::new(Affiliation::None, Role::None);
|
vec![MucItem::new(Affiliation::None, Role::None)
|
||||||
item.reason =
|
.with_reason("You are not in the room.")]
|
||||||
Some(Reason(String::from("You are not in the room.")));
|
|
||||||
vec![item]
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
.into()]);
|
.into()]);
|
||||||
|
|
|
@ -787,11 +787,9 @@ mod tests {
|
||||||
.with_to(ROSA_FULL1.clone())
|
.with_to(ROSA_FULL1.clone())
|
||||||
.with_payloads(vec![MucUser {
|
.with_payloads(vec![MucUser {
|
||||||
status: vec![MucStatus::SelfPresence],
|
status: vec![MucStatus::SelfPresence],
|
||||||
items: vec![{
|
items: vec![
|
||||||
let mut item = MucItem::new(Affiliation::Owner, Role::None);
|
MucItem::new(Affiliation::Owner, Role::None).with_jid(ROSA_FULL1.clone())
|
||||||
item.jid = Some(ROSA_FULL1.clone());
|
],
|
||||||
item
|
|
||||||
}],
|
|
||||||
}
|
}
|
||||||
.into()]),
|
.into()]),
|
||||||
);
|
);
|
||||||
|
|
|
@ -29,7 +29,7 @@ use xmpp_parsers::{
|
||||||
delay::Delay,
|
delay::Delay,
|
||||||
message::{Message, MessageType, Subject as MessageSubject},
|
message::{Message, MessageType, Subject as MessageSubject},
|
||||||
muc::{
|
muc::{
|
||||||
user::{Affiliation, Item as MucItem, Reason, Role, Status as MucStatus},
|
user::{Affiliation, Item as MucItem, Role, Status as MucStatus},
|
||||||
Muc, MucUser,
|
Muc, MucUser,
|
||||||
},
|
},
|
||||||
presence::{Presence, Show as PresenceShow, Type as PresenceType},
|
presence::{Presence, Show as PresenceShow, Type as PresenceType},
|
||||||
|
@ -59,11 +59,8 @@ async fn join_empty_room() {
|
||||||
.with_to(Jid::Full(LOUISE_FULL1.clone()))
|
.with_to(Jid::Full(LOUISE_FULL1.clone()))
|
||||||
.with_payloads(vec![MucUser {
|
.with_payloads(vec![MucUser {
|
||||||
status: vec![MucStatus::SelfPresence, MucStatus::AssignedNick],
|
status: vec![MucStatus::SelfPresence, MucStatus::AssignedNick],
|
||||||
items: vec![{
|
items: vec![MucItem::new(Affiliation::Owner, Role::Moderator)
|
||||||
let mut item = MucItem::new(Affiliation::Owner, Role::Moderator);
|
.with_jid(LOUISE_FULL1.clone())],
|
||||||
item.jid = Some(LOUISE_FULL1.clone());
|
|
||||||
item
|
|
||||||
}],
|
|
||||||
}
|
}
|
||||||
.into()]),
|
.into()]),
|
||||||
);
|
);
|
||||||
|
@ -220,11 +217,8 @@ async fn join_existing_room() {
|
||||||
.with_to(Jid::Full(SUGAKO_FULL1.clone()))
|
.with_to(Jid::Full(SUGAKO_FULL1.clone()))
|
||||||
.with_payloads(vec![MucUser {
|
.with_payloads(vec![MucUser {
|
||||||
status: vec![MucStatus::SelfPresence, MucStatus::AssignedNick],
|
status: vec![MucStatus::SelfPresence, MucStatus::AssignedNick],
|
||||||
items: vec![{
|
items: vec![MucItem::new(Affiliation::Owner, Role::Moderator)
|
||||||
let mut item = MucItem::new(Affiliation::Owner, Role::Moderator);
|
.with_jid(SUGAKO_FULL1.clone())],
|
||||||
item.jid = Some(SUGAKO_FULL1.clone());
|
|
||||||
item
|
|
||||||
}],
|
|
||||||
}
|
}
|
||||||
.into()]),
|
.into()]),
|
||||||
);
|
);
|
||||||
|
@ -336,11 +330,8 @@ async fn resync() {
|
||||||
.with_to(Jid::Full(LOUISE_FULL1.clone()))
|
.with_to(Jid::Full(LOUISE_FULL1.clone()))
|
||||||
.with_payloads(vec![MucUser {
|
.with_payloads(vec![MucUser {
|
||||||
status: vec![MucStatus::SelfPresence, MucStatus::AssignedNick],
|
status: vec![MucStatus::SelfPresence, MucStatus::AssignedNick],
|
||||||
items: vec![{
|
items: vec![MucItem::new(Affiliation::Owner, Role::Moderator)
|
||||||
let mut item = MucItem::new(Affiliation::Owner, Role::Moderator);
|
.with_jid(LOUISE_FULL1.clone())],
|
||||||
item.jid = Some(LOUISE_FULL1.clone());
|
|
||||||
item
|
|
||||||
}],
|
|
||||||
}
|
}
|
||||||
.into()]),
|
.into()]),
|
||||||
);
|
);
|
||||||
|
@ -401,11 +392,9 @@ async fn leave_last_participant() {
|
||||||
.with_to(Jid::Full(LOUISE_FULL1.clone()))
|
.with_to(Jid::Full(LOUISE_FULL1.clone()))
|
||||||
.with_payloads(vec![MucUser {
|
.with_payloads(vec![MucUser {
|
||||||
status: vec![MucStatus::SelfPresence],
|
status: vec![MucStatus::SelfPresence],
|
||||||
items: vec![{
|
items: vec![
|
||||||
let mut item = MucItem::new(Affiliation::Owner, Role::None);
|
MucItem::new(Affiliation::Owner, Role::None).with_jid(LOUISE_FULL1.clone())
|
||||||
item.jid = Some(LOUISE_FULL1.clone());
|
],
|
||||||
item
|
|
||||||
}],
|
|
||||||
}
|
}
|
||||||
.into()]),
|
.into()]),
|
||||||
);
|
);
|
||||||
|
@ -486,11 +475,9 @@ async fn leave_room_not_last() {
|
||||||
.with_to(Jid::Full(SUGAKO_FULL1.clone()))
|
.with_to(Jid::Full(SUGAKO_FULL1.clone()))
|
||||||
.with_payloads(vec![MucUser {
|
.with_payloads(vec![MucUser {
|
||||||
status: vec![MucStatus::SelfPresence],
|
status: vec![MucStatus::SelfPresence],
|
||||||
items: vec![{
|
items: vec![
|
||||||
let mut item = MucItem::new(Affiliation::Owner, Role::None);
|
MucItem::new(Affiliation::Owner, Role::None).with_jid(SUGAKO_FULL1.clone())
|
||||||
item.jid = Some(SUGAKO_FULL1.clone());
|
],
|
||||||
item
|
|
||||||
}],
|
|
||||||
}
|
}
|
||||||
.into()]),
|
.into()]),
|
||||||
);
|
);
|
||||||
|
@ -566,9 +553,8 @@ async fn update_not_joined() {
|
||||||
MucStatus::ServiceErrorKick,
|
MucStatus::ServiceErrorKick,
|
||||||
],
|
],
|
||||||
items: {
|
items: {
|
||||||
let mut item = MucItem::new(Affiliation::None, Role::None);
|
vec![MucItem::new(Affiliation::None, Role::None)
|
||||||
item.reason = Some(Reason(String::from("You are not in the room.")));
|
.with_reason("You are not in the room.")]
|
||||||
vec![item]
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
.into()]),
|
.into()]),
|
||||||
|
|
|
@ -55,11 +55,8 @@ async fn join() {
|
||||||
.with_to(Jid::Full(LOUISE_FULL1.clone()))
|
.with_to(Jid::Full(LOUISE_FULL1.clone()))
|
||||||
.with_payloads(vec![MucUser {
|
.with_payloads(vec![MucUser {
|
||||||
status: vec![MucStatus::SelfPresence, MucStatus::AssignedNick],
|
status: vec![MucStatus::SelfPresence, MucStatus::AssignedNick],
|
||||||
items: vec![{
|
items: vec![MucItem::new(Affiliation::Owner, Role::Moderator)
|
||||||
let mut item = MucItem::new(Affiliation::Owner, Role::Moderator);
|
.with_jid(LOUISE_FULL1.clone())],
|
||||||
item.jid = Some(LOUISE_FULL1.clone());
|
|
||||||
item
|
|
||||||
}],
|
|
||||||
}
|
}
|
||||||
.into()]),
|
.into()]),
|
||||||
);
|
);
|
||||||
|
@ -78,14 +75,12 @@ async fn join() {
|
||||||
.with_to(Jid::Full(LOUISE_FULL1.clone()))
|
.with_to(Jid::Full(LOUISE_FULL1.clone()))
|
||||||
.with_payloads(vec![MucUser {
|
.with_payloads(vec![MucUser {
|
||||||
status: Vec::new(),
|
status: Vec::new(),
|
||||||
items: {
|
items: vec![
|
||||||
let item = MucItem::new(Affiliation::Owner, Role::Moderator);
|
MucItem::new(Affiliation::Owner, Role::Moderator)
|
||||||
let mut item1 = item.clone();
|
.with_jid(LOUISE_FULL1.clone()),
|
||||||
item1.jid = Some(LOUISE_FULL1.clone());
|
MucItem::new(Affiliation::Owner, Role::Moderator)
|
||||||
let mut item2 = item.clone();
|
.with_jid(LOUISE_FULL2.clone()),
|
||||||
item2.jid = Some(LOUISE_FULL2.clone());
|
],
|
||||||
vec![item1, item2]
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
.into()]),
|
.into()]),
|
||||||
);
|
);
|
||||||
|
@ -97,14 +92,12 @@ async fn join() {
|
||||||
.with_to(Jid::Full(LOUISE_FULL2.clone()))
|
.with_to(Jid::Full(LOUISE_FULL2.clone()))
|
||||||
.with_payloads(vec![MucUser {
|
.with_payloads(vec![MucUser {
|
||||||
status: vec![MucStatus::SelfPresence, MucStatus::AssignedNick],
|
status: vec![MucStatus::SelfPresence, MucStatus::AssignedNick],
|
||||||
items: {
|
items: vec![
|
||||||
let item = MucItem::new(Affiliation::Owner, Role::Moderator);
|
MucItem::new(Affiliation::Owner, Role::Moderator)
|
||||||
let mut item1 = item.clone();
|
.with_jid(LOUISE_FULL1.clone()),
|
||||||
item1.jid = Some(LOUISE_FULL1.clone());
|
MucItem::new(Affiliation::Owner, Role::Moderator)
|
||||||
let mut item2 = item.clone();
|
.with_jid(LOUISE_FULL2.clone()),
|
||||||
item2.jid = Some(LOUISE_FULL2.clone());
|
],
|
||||||
vec![item1, item2]
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
.into()]),
|
.into()]),
|
||||||
);
|
);
|
||||||
|
@ -167,13 +160,11 @@ async fn leave() {
|
||||||
.with_to(Jid::Full(LOUISE_FULL2.clone()))
|
.with_to(Jid::Full(LOUISE_FULL2.clone()))
|
||||||
.with_payloads(vec![MucUser {
|
.with_payloads(vec![MucUser {
|
||||||
status: vec![MucStatus::SelfPresence],
|
status: vec![MucStatus::SelfPresence],
|
||||||
items: {
|
items: vec![
|
||||||
let mut item1 = MucItem::new(Affiliation::Owner, Role::Moderator);
|
MucItem::new(Affiliation::Owner, Role::Moderator)
|
||||||
item1.jid = Some(LOUISE_FULL1.clone());
|
.with_jid(LOUISE_FULL1.clone()),
|
||||||
let mut item2 = MucItem::new(Affiliation::Owner, Role::None);
|
MucItem::new(Affiliation::Owner, Role::None).with_jid(LOUISE_FULL2.clone()),
|
||||||
item2.jid = Some(LOUISE_FULL2.clone());
|
],
|
||||||
vec![item1, item2]
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
.into()]),
|
.into()]),
|
||||||
);
|
);
|
||||||
|
@ -185,13 +176,11 @@ async fn leave() {
|
||||||
.with_to(Jid::Full(LOUISE_FULL1.clone()))
|
.with_to(Jid::Full(LOUISE_FULL1.clone()))
|
||||||
.with_payloads(vec![MucUser {
|
.with_payloads(vec![MucUser {
|
||||||
status: vec![],
|
status: vec![],
|
||||||
items: {
|
items: vec![
|
||||||
let mut item1 = MucItem::new(Affiliation::Owner, Role::Moderator);
|
MucItem::new(Affiliation::Owner, Role::Moderator)
|
||||||
item1.jid = Some(LOUISE_FULL1.clone());
|
.with_jid(LOUISE_FULL1.clone()),
|
||||||
let mut item2 = MucItem::new(Affiliation::Owner, Role::None);
|
MucItem::new(Affiliation::Owner, Role::None).with_jid(LOUISE_FULL2.clone()),
|
||||||
item2.jid = Some(LOUISE_FULL2.clone());
|
],
|
||||||
vec![item1, item2]
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
.into()]),
|
.into()]),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue