Comparison

plugins/mod_lastactivity.lua @ 10758:d0e6d5bc7ea2

Merge with upstream trunk
author Matthew Wild <mwild1@gmail.com>
date Thu, 23 Apr 2020 13:53:18 +0100
parent 10750:ff087f2d4cb6
child 12977:74b9e05af71e
comparison
equal deleted inserted replaced
10757:9dec7cddb40b 10758:d0e6d5bc7ea2
28 local origin, stanza = event.origin, event.stanza; 28 local origin, stanza = event.origin, event.stanza;
29 local username = jid_split(stanza.attr.to) or origin.username; 29 local username = jid_split(stanza.attr.to) or origin.username;
30 if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then 30 if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then
31 local seconds, text = "0", ""; 31 local seconds, text = "0", "";
32 if map[username] then 32 if map[username] then
33 seconds = tostring(os.difftime(os.time(), map[username].t)); 33 seconds = string.format("%d", os.difftime(os.time(), map[username].t));
34 text = map[username].s; 34 text = map[username].s;
35 end 35 end
36 origin.send(st.reply(stanza):tag('query', {xmlns='jabber:iq:last', seconds=seconds}):text(text)); 36 origin.send(st.reply(stanza):tag('query', {xmlns='jabber:iq:last', seconds=seconds}):text(text));
37 else 37 else
38 origin.send(st.error_reply(stanza, 'auth', 'forbidden')); 38 origin.send(st.error_reply(stanza, 'auth', 'forbidden'));