plugins/mod_xmlrpc.lua

changeset 1590
638761692663
parent 1587
81992255a374
child 1591
aaa1bcb7af98
equal deleted inserted replaced
1589:812ae3be7bed 1590:638761692663
65 end 65 end
66 return stanza.tags[1]; 66 return stanza.tags[1];
67 end 67 end
68 68
69 local function handle_xmlrpc_request(jid, method, args) 69 local function handle_xmlrpc_request(jid, method, args)
70 local is_secure_call = (method:sub(1,7) ~= "secure/"); 70 local is_secure_call = (method:sub(1,7) == "secure/");
71 if not is_admin(jid) and not is_secure_call then 71 if not is_admin(jid) and not is_secure_call then
72 return create_error_response(401, "not authorized"); 72 return create_error_response(401, "not authorized");
73 end 73 end
74 method = get_method(method); 74 method = get_method(method);
75 if not method then return create_error_response(404, "method not found"); end 75 if not method then return create_error_response(404, "method not found"); end
76 args = args or {}; 76 args = args or {};
77 if is_secure_call then t_insert(args, 1, jid); end 77 if is_secure_call then table.insert(args, 1, jid); end
78 local success, result = pcall(method, unpack(args)); 78 local success, result = pcall(method, unpack(args));
79 if success then 79 if success then
80 success, result = pcall(create_response, result or "nil"); 80 success, result = pcall(create_response, result or "nil");
81 if success then 81 if success then
82 return result; 82 return result;

mercurial