aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-08-24 20:34:34 +0200
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-08-24 20:34:34 +0200
commit08c4231d4a1a2bca43954205316d308b5d6d7890 (patch)
tree9c1ff1f7475d182a3af6ca524cf15895cde495e2
parent00d9da2914d810dd64cf2161273d2899d3537fc7 (diff)
downloadprosody-08c4231d4a1a2bca43954205316d308b5d6d7890.tar.gz
prosody-08c4231d4a1a2bca43954205316d308b5d6d7890.zip
mod_lastactivity: Simplify iq handling by hooking on iq-get/ instead of iq/.
-rw-r--r--plugins/mod_lastactivity.lua24
1 files changed, 11 insertions, 13 deletions
diff --git a/plugins/mod_lastactivity.lua b/plugins/mod_lastactivity.lua
index 2dd61699..575e66be 100644
--- a/plugins/mod_lastactivity.lua
+++ b/plugins/mod_lastactivity.lua
@@ -24,22 +24,20 @@ module:hook("pre-presence/bare", function(event)
end
end, 10);
-module:hook("iq/bare/jabber:iq:last:query", function(event)
+module:hook("iq-get/bare/jabber:iq:last:query", function(event)
local origin, stanza = event.origin, event.stanza;
- if stanza.attr.type == "get" then
- local username = jid_split(stanza.attr.to) or origin.username;
- if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then
- local seconds, text = "0", "";
- if map[username] then
- seconds = tostring(os.difftime(os.time(), map[username].t));
- text = map[username].s;
- end
- origin.send(st.reply(stanza):tag('query', {xmlns='jabber:iq:last', seconds=seconds}):text(text));
- else
- origin.send(st.error_reply(stanza, 'auth', 'forbidden'));
+ local username = jid_split(stanza.attr.to) or origin.username;
+ if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then
+ local seconds, text = "0", "";
+ if map[username] then
+ seconds = tostring(os.difftime(os.time(), map[username].t));
+ text = map[username].s;
end
- return true;
+ origin.send(st.reply(stanza):tag('query', {xmlns='jabber:iq:last', seconds=seconds}):text(text));
+ else
+ origin.send(st.error_reply(stanza, 'auth', 'forbidden'));
end
+ return true;
end);
module.save = function()