Comparison

mod_idlecompat/mod_idlecompat.lua @ 2165:e0b8b8a50013

Merge with Link Mauve
author Kim Alvefur <zash@zash.se>
date Sun, 17 Apr 2016 21:41:48 +0200
parent 2164:4b58e35a72e0
comparison
equal deleted inserted replaced
2163:88fec2b2bd58 2165:e0b8b8a50013
1 -- Last User Interaction in Presence via Last Activity compatibility module 1 -- Last User Interaction in Presence via Last Activity compatibility module
2 -- http://xmpp.org/extensions/xep-0319.html 2 -- http://xmpp.org/extensions/xep-0319.html
3 -- http://xmpp.org/extensions/xep-0012.html 3 -- http://xmpp.org/extensions/xep-0256.html
4 -- Copyright (C) 2014 Tobias Markmann 4 -- Copyright (C) 2014 Tobias Markmann
5 -- 5 --
6 -- This file is MIT/X11 licensed. 6 -- This file is MIT/X11 licensed.
7 7
8 local st = require "util.stanza"; 8 local st = require "util.stanza";
9 local datetime = require "util.datetime"; 9 local datetime = require "util.datetime";
10 10
11 local function on_presence(event) 11 local function on_presence(event)
12 local stanza = event.stanza; 12 local stanza = event.stanza;
13 13
14 local last_activity = stanza.name == "presence" and stanza:get_child("query", "jabber:iq:last") or false; 14 local last_activity = stanza:get_child("query", "jabber:iq:last");
15 local has_idle = stanza:get_child("idle", "urn:xmpp:idle:1"); 15 local has_idle = stanza:get_child("idle", "urn:xmpp:idle:1");
16 if last_activity and not has_idle then 16 if last_activity and not has_idle then
17 module:log("debug", "Adding XEP-0319 tag from Last Activity."); 17 module:log("debug", "Adding XEP-0319 tag from Last Activity.");
18 local seconds = last_activity.attr.seconds; 18 local seconds = last_activity.attr.seconds;
19 local last_userinteraction = datetime.datetime(os.time() - seconds); 19 local last_userinteraction = datetime.datetime(os.time() - seconds);