Move delay namespace out of the constructor

This commit is contained in:
Mikhail 2024-05-24 19:25:08 +02:00
parent 6def71b581
commit 8d2e56fac9
2 changed files with 6 additions and 16 deletions

View File

@ -149,14 +149,14 @@ impl<'a> XmppConnection<'a> {
server: Server(self.hostname_rooms.clone()), server: Server(self.hostname_rooms.clone()),
resource: Option::from(Resource(history_message.author.name.clone().into())), resource: Option::from(Resource(history_message.author.name.clone().into())),
}, },
delay: Delay::new( delay: Delay {
Jid { from: Jid {
name: Option::from(Name(history_message.author.name.clone().into())), name: Option::from(Name(history_message.author.name.clone().into())),
server: Server(self.hostname_rooms.clone()), server: Server(self.hostname_rooms.clone()),
resource: None, resource: None,
}, },
history_message.created_at.to_rfc3339(), stamp: history_message.created_at.to_rfc3339(),
), },
body: history_message.content.clone(), body: history_message.content.clone(),
}); });
tracing::info!( tracing::info!(

View File

@ -10,6 +10,7 @@ use crate::xml::*;
pub const XMLNS: &'static str = "http://jabber.org/protocol/muc"; pub const XMLNS: &'static str = "http://jabber.org/protocol/muc";
pub const XMLNS_USER: &'static str = "http://jabber.org/protocol/muc#user"; pub const XMLNS_USER: &'static str = "http://jabber.org/protocol/muc#user";
pub const XMLNS_DELAY: &'static str = "urn:xmpp:delay";
#[derive(PartialEq, Eq, Debug, Default)] #[derive(PartialEq, Eq, Debug, Default)]
pub struct History { pub struct History {
@ -253,27 +254,16 @@ impl Role {
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub struct Delay { pub struct Delay {
pub xmlns: String,
pub from: Jid, pub from: Jid,
pub stamp: String, pub stamp: String,
} }
impl Delay {
pub fn new(from: Jid, stamp: String) -> Self {
Self {
xmlns: "urn:xmpp:delay".into(),
from,
stamp,
}
}
}
impl ToXml for Delay { impl ToXml for Delay {
fn serialize(&self, events: &mut Vec<Event>) { fn serialize(&self, events: &mut Vec<Event>) {
let mut tag = BytesStart::new("delay"); let mut tag = BytesStart::new("delay");
tag.push_attribute(Attribute { tag.push_attribute(Attribute {
key: QName(b"xmlns"), key: QName(b"xmlns"),
value: self.xmlns.as_bytes().into(), value: XMLNS_DELAY.as_bytes().into(),
}); });
tag.push_attribute(Attribute { tag.push_attribute(Attribute {
key: QName(b"from"), key: QName(b"from"),