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()),
resource: Option::from(Resource(history_message.author.name.clone().into())),
},
delay: Delay::new(
Jid {
delay: Delay {
from: Jid {
name: Option::from(Name(history_message.author.name.clone().into())),
server: Server(self.hostname_rooms.clone()),
resource: None,
},
history_message.created_at.to_rfc3339(),
),
stamp: history_message.created_at.to_rfc3339(),
},
body: history_message.content.clone(),
});
tracing::info!(

View File

@ -10,6 +10,7 @@ use crate::xml::*;
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_DELAY: &'static str = "urn:xmpp:delay";
#[derive(PartialEq, Eq, Debug, Default)]
pub struct History {
@ -253,27 +254,16 @@ impl Role {
#[derive(Debug, PartialEq, Eq)]
pub struct Delay {
pub xmlns: String,
pub from: Jid,
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 {
fn serialize(&self, events: &mut Vec<Event>) {
let mut tag = BytesStart::new("delay");
tag.push_attribute(Attribute {
key: QName(b"xmlns"),
value: self.xmlns.as_bytes().into(),
value: XMLNS_DELAY.as_bytes().into(),
});
tag.push_attribute(Attribute {
key: QName(b"from"),