Software / code / prosody
Comparison
plugins/mod_lastactivity.lua @ 11120:b2331f3dfeea
Merge 0.11->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 30 Sep 2020 09:50:33 +0100 |
| parent | 10750:ff087f2d4cb6 |
| child | 12977:74b9e05af71e |
comparison
equal
deleted
inserted
replaced
| 11119:68df52bf08d5 | 11120:b2331f3dfeea |
|---|---|
| 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')); |