diff options
author | Edwin Mons <edwin.mons@isode.com> | 2014-05-12 11:25:41 (GMT) |
---|---|---|
committer | Edwin Mons <edwin.mons@isode.com> | 2014-05-12 13:26:03 (GMT) |
commit | e5fc9da99eae0d54b4ff5607016fbacfdbf55485 (patch) | |
tree | c43ce6dd8264c87211ca64f9d5fed9740fcd58f0 | |
parent | 15ccd713a988b8386d06ca9ea10910ae9f59ea5a (diff) | |
download | swift-contrib-e5fc9da99eae0d54b4ff5607016fbacfdbf55485.zip swift-contrib-e5fc9da99eae0d54b4ff5607016fbacfdbf55485.tar.bz2 |
Fix to Sluift MAM query parameters
Change-Id: Ieefb87795316ffa4f513cf1d19d20730596db6d9
-rw-r--r-- | Sluift/client.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/Sluift/client.cpp b/Sluift/client.cpp index 1cdd8d7..8dcd9ae 100644 --- a/Sluift/client.cpp +++ b/Sluift/client.cpp @@ -463,21 +463,19 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( "See help('MAMQuery') for details." ) { - if (!lua_istable(L, 2)) { - throw Lua::Exception("Missing MAMQuery"); - } - if (boost::shared_ptr<MAMQuery> mamQuery = boost::dynamic_pointer_cast<MAMQuery>(Sluift::globals.elementConvertor.convertFromLuaUntyped(L, 2, "mam_query"))) { - IQRouter *router = getClient(L)->getClient()->getIQRouter(); - JID jid; - lua_getfield(L, 2, "jid"); - if (!lua_isnil(L, -1)) { - jid = JID(lua_tostring(L, -1)); - } - router->sendIQ(IQ::createRequest(IQ::Set, jid, IDGenerator().generateID(), mamQuery)); + Lua::checkType(L, 2, LUA_TTABLE); + boost::shared_ptr<MAMQuery> mamQuery = boost::make_shared<MAMQuery>(); + lua_getfield(L, 2, "mam_query"); + if (lua_istable(L, -1)) { + mamQuery = boost::dynamic_pointer_cast<MAMQuery>(Sluift::globals.elementConvertor.convertFromLuaUntyped(L, -1, "mam_query")); } - else { - throw Lua::Exception("Illegal MAMQuery"); + JID jid; + lua_getfield(L, 2, "jid"); + if (!lua_isnil(L, -1)) { + jid = JID(lua_tostring(L, -1)); } + IQRouter *router = getClient(L)->getClient()->getIQRouter(); + router->sendIQ(IQ::createRequest(IQ::Set, jid, IDGenerator().generateID(), mamQuery)); return 0; } |