forked from lavina/lavina
Compare commits
No commits in common. "6def71b581e829dcf33ce4820b63db5e1df2313b" and "85c8d03f542bb41bbd1d7562ce65112d3aae48ec" have entirely different histories.
6def71b581
...
85c8d03f54
|
@ -130,7 +130,6 @@ impl<'a> XmppConnection<'a> {
|
||||||
<body></body>
|
<body></body>
|
||||||
</message>
|
</message>
|
||||||
*/
|
*/
|
||||||
#[tracing::instrument(skip(self), name = "XmppConnection::retrieve_message_history")]
|
|
||||||
async fn retrieve_message_history(&self, room_name: &Name) -> Result<(Vec<XmppHistoryMessage>)> {
|
async fn retrieve_message_history(&self, room_name: &Name) -> Result<(Vec<XmppHistoryMessage>)> {
|
||||||
let room_id = RoomId::try_from(room_name.0.clone())?;
|
let room_id = RoomId::try_from(room_name.0.clone())?;
|
||||||
let history_messages = self.user_handle.get_room_message_history(room_id).await?;
|
let history_messages = self.user_handle.get_room_message_history(room_id).await?;
|
||||||
|
|
|
@ -268,33 +268,6 @@ impl Delay {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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(),
|
|
||||||
});
|
|
||||||
tag.push_attribute(Attribute {
|
|
||||||
key: QName(b"from"),
|
|
||||||
value: self.from.to_string().into_bytes().into(),
|
|
||||||
});
|
|
||||||
tag.push_attribute(Attribute {
|
|
||||||
key: QName(b"stamp"),
|
|
||||||
value: self.stamp.as_bytes().into(),
|
|
||||||
});
|
|
||||||
events.push(Event::Empty(tag));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Example of an XMPP message with history stanza:
|
|
||||||
|
|
||||||
<message from="duqedadi@conference.oflor.me/misha" xml:lang="en" to="misha@oflor.me/tux" type="groupchat" id="7ca7cb14-b2af-49c9-bd90-05dabb1113a5">
|
|
||||||
<delay xmlns="urn:xmpp:delay" stamp="2024-05-17T16:05:28.440337Z" from="duqedadi@conference.oflor.me"/>
|
|
||||||
<body></body>
|
|
||||||
</message>
|
|
||||||
*/
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct XmppHistoryMessage {
|
pub struct XmppHistoryMessage {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
|
@ -306,27 +279,40 @@ pub struct XmppHistoryMessage {
|
||||||
|
|
||||||
impl ToXml for XmppHistoryMessage {
|
impl ToXml for XmppHistoryMessage {
|
||||||
fn serialize(&self, events: &mut Vec<Event<'static>>) {
|
fn serialize(&self, events: &mut Vec<Event<'static>>) {
|
||||||
let mut message_tag = BytesStart::new("message");
|
let mut tag = BytesStart::new("message");
|
||||||
message_tag.push_attribute(Attribute {
|
tag.push_attribute(Attribute {
|
||||||
key: QName(b"id"),
|
key: QName(b"id"),
|
||||||
value: self.id.as_str().as_bytes().into(),
|
value: self.id.as_str().as_bytes().into(),
|
||||||
});
|
});
|
||||||
message_tag.push_attribute(Attribute {
|
tag.push_attribute(Attribute {
|
||||||
key: QName(b"to"),
|
key: QName(b"to"),
|
||||||
value: self.to.to_string().into_bytes().into(),
|
value: self.to.to_string().into_bytes().into(),
|
||||||
});
|
});
|
||||||
message_tag.push_attribute(Attribute {
|
tag.push_attribute(Attribute {
|
||||||
key: QName(b"from"),
|
key: QName(b"from"),
|
||||||
value: self.from.to_string().into_bytes().into(),
|
value: self.from.to_string().into_bytes().into(),
|
||||||
});
|
});
|
||||||
message_tag.push_attribute(Attribute {
|
tag.push_attribute(Attribute {
|
||||||
key: QName(b"type"),
|
key: QName(b"type"),
|
||||||
value: b"groupchat".into(),
|
value: b"groupchat".into(),
|
||||||
});
|
});
|
||||||
events.push(Event::Start(message_tag));
|
events.push(Event::Start(tag));
|
||||||
self.delay.serialize(events);
|
let mut tag = BytesStart::new("delay");
|
||||||
let body_tag = BytesStart::new("body");
|
tag.push_attribute(Attribute {
|
||||||
events.push(Event::Start(body_tag));
|
key: QName(b"xmlns"),
|
||||||
|
value: self.delay.xmlns.as_bytes().into(),
|
||||||
|
});
|
||||||
|
tag.push_attribute(Attribute {
|
||||||
|
key: QName(b"from"),
|
||||||
|
value: self.delay.from.to_string().into_bytes().into(),
|
||||||
|
});
|
||||||
|
tag.push_attribute(Attribute {
|
||||||
|
key: QName(b"stamp"),
|
||||||
|
value: self.delay.stamp.as_bytes().into(),
|
||||||
|
});
|
||||||
|
events.push(Event::Empty(tag));
|
||||||
|
let mut tag = BytesStart::new("body");
|
||||||
|
events.push(Event::Start(tag));
|
||||||
events.push(Event::Text(BytesText::new(self.body.to_string().as_str()).into_owned()));
|
events.push(Event::Text(BytesText::new(self.body.to_string().as_str()).into_owned()));
|
||||||
events.push(Event::End(BytesEnd::new("body")));
|
events.push(Event::End(BytesEnd::new("body")));
|
||||||
events.push(Event::End(BytesEnd::new("message")));
|
events.push(Event::End(BytesEnd::new("message")));
|
||||||
|
|
Loading…
Reference in New Issue