mod_csi_simple: Consider messages encrypted payload as important (fixes part of ...
[prosody.git] / plugins / mod_time.lua
blob0cd5a4ea4cd6775725428efe3ae2b4d316ff0acd
1 -- Prosody IM
2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
4 --
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
9 local st = require "util.stanza";
10 local datetime = require "util.datetime".datetime;
11 local legacy = require "util.datetime".legacy;
13 -- XEP-0202: Entity Time
15 module:add_feature("urn:xmpp:time");
17 local function time_handler(event)
18 local origin, stanza = event.origin, event.stanza;
19 origin.send(st.reply(stanza):tag("time", {xmlns="urn:xmpp:time"})
20 :tag("tzo"):text("+00:00"):up() -- TODO get the timezone in a platform independent fashion
21 :tag("utc"):text(datetime()));
22 return true;
23 end
25 module:hook("iq-get/bare/urn:xmpp:time:time", time_handler);
26 module:hook("iq-get/host/urn:xmpp:time:time", time_handler);
28 -- XEP-0090: Entity Time (deprecated)
30 module:add_feature("jabber:iq:time");
32 local function legacy_time_handler(event)
33 local origin, stanza = event.origin, event.stanza;
34 origin.send(st.reply(stanza):tag("query", {xmlns="jabber:iq:time"})
35 :tag("utc"):text(legacy()));
36 return true;
37 end
39 module:hook("iq-get/bare/jabber:iq:time:query", legacy_time_handler);
40 module:hook("iq-get/host/jabber:iq:time:query", legacy_time_handler);