From e5fc9da99eae0d54b4ff5607016fbacfdbf55485 Mon Sep 17 00:00:00 2001 From: Edwin Mons <edwin.mons@isode.com> Date: Mon, 12 May 2014 13:25:41 +0200 Subject: Fix to Sluift MAM query parameters Change-Id: Ieefb87795316ffa4f513cf1d19d20730596db6d9 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; } -- cgit v0.10.2-6-g49f6