interpreter: feed in default namespaces
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
b7399dc9a5
commit
365f5d60a2
1 changed files with 20 additions and 5 deletions
|
@ -13,12 +13,13 @@
|
|||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::element::ScanElement;
|
||||
use crate::element::{ScanElement, DEFAULT_NS, SCANSION_NS};
|
||||
use crate::parsers::{parse_spec, Token};
|
||||
use crate::types::{Action, Context, Entity, Spec};
|
||||
use jid::Jid;
|
||||
use minidom::{Element, Error as MinidomError};
|
||||
use rand::{thread_rng, Rng};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
#[cfg_attr(test, derive(PartialEq))]
|
||||
#[derive(Debug)]
|
||||
|
@ -82,16 +83,30 @@ pub fn read_actions(spec: Spec, context: &Context) -> Result<InOutStanza, Minido
|
|||
.get(&name)
|
||||
.expect(format!("Name '{}' not found in clients", name).as_str());
|
||||
|
||||
let elem = s.parse::<Element>()?;
|
||||
inout.receives(ScanElement::new(elem).with_context(Some(&context)));
|
||||
let prefixes: BTreeMap<Option<String>, String> = {
|
||||
let mut tmp = BTreeMap::new();
|
||||
tmp.insert(None, String::from(DEFAULT_NS));
|
||||
tmp.insert(Some(String::from("scansion")), String::from(SCANSION_NS));
|
||||
tmp
|
||||
};
|
||||
|
||||
let elem = Element::from_reader_with_prefixes(s.as_ref(), prefixes)?;
|
||||
inout.receives(ScanElement::new(elem).apply_context(&context));
|
||||
}
|
||||
Action::Send(name, s) => {
|
||||
let _ = context
|
||||
.get(&name)
|
||||
.expect(format!("Name '{}' not found in clients", name).as_str());
|
||||
|
||||
let elem = s.parse::<Element>()?;
|
||||
inout.sends(ScanElement::new(elem).with_context(Some(&context)));
|
||||
let prefixes: BTreeMap<Option<String>, String> = {
|
||||
let mut tmp = BTreeMap::new();
|
||||
tmp.insert(None, String::from(DEFAULT_NS));
|
||||
tmp.insert(Some(String::from("scansion")), String::from(SCANSION_NS));
|
||||
tmp
|
||||
};
|
||||
|
||||
let elem = Element::from_reader_with_prefixes(s.as_ref(), prefixes)?;
|
||||
inout.sends(ScanElement::new(elem).apply_context(&context));
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue