2 -- Copyright (C) 2008-2009 Matthew Wild
3 -- Copyright (C) 2008-2009 Waqas Hussain
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
11 local st = require "util.stanza"
13 local jid_split = require "util.jid".split;
14 local t_concat = table.concat;
16 local start_time = prosody.start_time;
18 prosody.events.add_handler("server-started", function () start_time = prosody.start_time end);
20 module:add_feature("jabber:iq:last");
22 module:add_iq_handler({"c2s", "s2sin"}, "jabber:iq:last",
23 function (origin, stanza)
24 if stanza.tags[1].name == "query" then
25 if stanza.attr.type == "get" then
26 local node, host, resource = jid_split(stanza.attr.to);
27 if node or resource then
30 origin.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:last", seconds = tostring(os.difftime(os.time(), start_time))}));