xmpp/message/receive/
group_chat.rsuse tokio_xmpp::{jid::Jid, parsers::message::Message};
use crate::{delay::StanzaTimeInfo, Agent, Event};
pub async fn handle_message_group_chat(
agent: &mut Agent,
events: &mut Vec<Event>,
from: Jid,
message: &Message,
time_info: StanzaTimeInfo,
) {
let langs: Vec<&str> = agent.lang.iter().map(String::as_str).collect();
if let Some((_lang, subject)) = message.get_best_subject(langs.clone()) {
events.push(Event::RoomSubject(
from.to_bare(),
from.resource().map(|x| x.to_string()),
subject.0.clone(),
time_info.clone(),
));
}
if let Some((_lang, body)) = message.get_best_body(langs) {
let event = match from.clone().try_into_full() {
Ok(full) => Event::RoomMessage(
message.id.clone(),
from.to_bare(),
full.resource().to_string(),
body.clone(),
time_info,
),
Err(bare) => Event::ServiceMessage(message.id.clone(), bare, body.clone(), time_info),
};
events.push(event)
}
}