parsers: impl MessagePayload for MucUser

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2023-06-07 16:46:43 +02:00
parent 6cd4addc1a
commit d0ec8739d5

View file

@ -5,6 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use crate::message::MessagePayload;
use crate::ns; use crate::ns;
use crate::presence::PresencePayload; use crate::presence::PresencePayload;
use crate::util::error::Error; use crate::util::error::Error;
@ -270,12 +271,15 @@ generate_element!(
] ]
); );
impl MessagePayload for MucUser {}
impl PresencePayload for MucUser {} impl PresencePayload for MucUser {}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::message::Message;
use crate::presence::{Presence, Type as PresenceType}; use crate::presence::{Presence, Type as PresenceType};
use crate::{BareJid, Jid};
#[test] #[test]
fn test_simple() { fn test_simple() {
@ -714,4 +718,14 @@ mod tests {
let presence = Presence::new(PresenceType::None).with_payloads(vec![elem]); let presence = Presence::new(PresenceType::None).with_payloads(vec![elem]);
assert_eq!(presence.payloads.len(), 1); assert_eq!(presence.payloads.len(), 1);
} }
#[test]
fn message_payload() {
let jid: Jid = Jid::Bare(BareJid::new("louise", "example.com"));
let elem: Element = "<x xmlns='http://jabber.org/protocol/muc#user'/>"
.parse()
.unwrap();
let message = Message::new(jid).with_payloads(vec![elem]);
assert_eq!(message.payloads.len(), 1);
}
} }