plugins/messaging: Body, Thread, Subject are now structs

This commit is contained in:
Maxime “pep” Buquet 2017-12-26 20:55:19 +00:00
parent 5508f5b388
commit 1a8ea2e383

View file

@ -7,7 +7,7 @@ use error::Error;
use jid::Jid; use jid::Jid;
use plugins::stanza::Message; use plugins::stanza::Message;
use xmpp_parsers::message::{MessagePayload, MessageType}; use xmpp_parsers::message::{MessagePayload, MessageType, Body};
use xmpp_parsers::chatstates::ChatState; use xmpp_parsers::chatstates::ChatState;
use xmpp_parsers::receipts::{Request, Received}; use xmpp_parsers::receipts::{Request, Received};
use xmpp_parsers::stanza_id::StanzaId; use xmpp_parsers::stanza_id::StanzaId;
@ -70,7 +70,7 @@ impl MessagingPlugin {
id: Some(self.proxy.gen_id()), id: Some(self.proxy.gen_id()),
bodies: { bodies: {
let mut bodies = BTreeMap::new(); let mut bodies = BTreeMap::new();
bodies.insert(String::new(), String::from(body)); bodies.insert(String::new(), Body(body.to_owned()));
bodies bodies
}, },
subjects: BTreeMap::new(), subjects: BTreeMap::new(),
@ -118,9 +118,9 @@ impl MessagingPlugin {
if message.bodies.contains_key("") { if message.bodies.contains_key("") {
self.proxy.dispatch(MessageEvent { self.proxy.dispatch(MessageEvent {
from: from, from: from,
body: message.bodies[""].clone(), body: message.bodies[""].clone().0,
subject: if message.subjects.contains_key("") { Some(message.subjects[""].clone()) } else { None }, subject: if message.subjects.contains_key("") { Some(message.subjects[""].clone().0) } else { None },
thread: message.thread.clone(), thread: match message.thread.clone() { Some(thread) => Some(thread.0), None => None },
}); });
} }
Propagation::Stop Propagation::Stop