xmpp: Add ServiceMessage event

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2023-02-26 17:42:44 +01:00
parent 8a823af56b
commit d7a1cd71a9
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -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 => {