From d7a1cd71a949876984b81eac575ae4f47d43fa70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sun, 26 Feb 2023 17:42:44 +0100 Subject: [PATCH] xmpp: Add ServiceMessage event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- xmpp/src/lib.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/xmpp/src/lib.rs b/xmpp/src/lib.rs index 01103beb..65aaa726 100644 --- a/xmpp/src/lib.rs +++ b/xmpp/src/lib.rs @@ -90,6 +90,7 @@ pub enum Event { RoomJoined(BareJid), RoomLeft(BareJid), RoomMessage(BareJid, RoomNick, Body), + ServiceMessage(BareJid, Body), HttpUploadedFile(String), } @@ -333,11 +334,14 @@ impl Agent { match message.get_best_body(langs) { Some((_lang, body)) => match message.type_ { MessageType::Groupchat => { - let event = Event::RoomMessage( - from.clone().into(), - FullJid::try_from(from.clone()).unwrap().resource, - body.clone(), - ); + let event = match from.clone() { + Jid::Full(full) => Event::RoomMessage( + from.clone().into(), + full.resource, + body.clone(), + ), + Jid::Bare(bare) => Event::ServiceMessage(bare, body.clone()), + }; events.push(event) } MessageType::Chat | MessageType::Normal => {