diff --git a/xmpp/examples/hello_bot.rs b/xmpp/examples/hello_bot.rs index 500f763..791e33f 100644 --- a/xmpp/examples/hello_bot.rs +++ b/xmpp/examples/hello_bot.rs @@ -51,7 +51,7 @@ async fn main() -> Result<(), Option<()>> { Event::ContactChanged(contact) => { println!("Contact {} changed.", contact.jid); } - Event::ChatMessage(jid, body) => { + Event::ChatMessage(_id, jid, body) => { println!("Message from {}: {}", jid, body.0); } Event::JoinRoom(jid, conference) => { @@ -81,7 +81,7 @@ async fn main() -> Result<(), Option<()>> { Event::RoomLeft(jid) => { println!("Left room {}.", jid); } - Event::RoomMessage(jid, nick, body) => { + Event::RoomMessage(_id, jid, nick, body) => { println!("Message in room {} from {}: {}", jid, nick, body.0); } Event::AvatarRetrieved(jid, path) => { diff --git a/xmpp/src/lib.rs b/xmpp/src/lib.rs index 65aaa72..cfe4d9e 100644 --- a/xmpp/src/lib.rs +++ b/xmpp/src/lib.rs @@ -72,6 +72,7 @@ pub enum ClientFeature { JoinRooms, } +pub type Id = Option; pub type RoomNick = String; #[derive(Debug)] @@ -83,14 +84,14 @@ pub enum Event { ContactChanged(RosterItem), #[cfg(feature = "avatars")] AvatarRetrieved(Jid, String), - ChatMessage(BareJid, Body), + ChatMessage(Id, BareJid, Body), JoinRoom(BareJid, Conference), LeaveRoom(BareJid), LeaveAllRooms, RoomJoined(BareJid), RoomLeft(BareJid), - RoomMessage(BareJid, RoomNick, Body), - ServiceMessage(BareJid, Body), + RoomMessage(Id, BareJid, RoomNick, Body), + ServiceMessage(Id, BareJid, Body), HttpUploadedFile(String), } @@ -336,16 +337,25 @@ impl Agent { MessageType::Groupchat => { let event = match from.clone() { Jid::Full(full) => Event::RoomMessage( + message.id.clone(), from.clone().into(), full.resource, body.clone(), ), - Jid::Bare(bare) => Event::ServiceMessage(bare, body.clone()), + Jid::Bare(bare) => Event::ServiceMessage( + message.id.clone(), + bare, + body.clone(), + ), }; events.push(event) } MessageType::Chat | MessageType::Normal => { - let event = Event::ChatMessage(from.clone().into(), body.clone()); + let event = Event::ChatMessage( + message.id.clone(), + from.clone().into(), + body.clone(), + ); events.push(event) } _ => (),