I don't speak lua :) Anyway, I looked into the code. Just some feedback. https://sources.debian.org/src/prosody/0.12.1-2/plugins/mod_lastactivity.lua/#L20 Maybe this will add time and status to a map of users, when they go offline.
https://sources.debian.org/src/prosody/0.12.1-2/plugins/mod_lastactivity.lua/#L36 This may the place where the 0 second will be returned. I'm just wondering about https://sources.debian.org/src/prosody/0.12.1-2/plugins/mod_lastactivity.lua/#L30 It's a "not stanza.attr.to or" where line 20 "use not(stanza.attr.to) and". Not sure what impact the or vs. and have there. Second point is, will the user been removed from the map, when they go online?