Mercurial > prosody-modules
changeset 1174:bd7901fef71b
mod_lastlog: If loaded on a component, store a timestamp of the last message sent, eg to a MUC room
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 28 Aug 2013 18:54:00 +0200 (2013-08-28) |
parents | 8999967fc4fe |
children | 9eac4e2386d2 |
files | mod_lastlog/mod_lastlog.lua |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_lastlog/mod_lastlog.lua Wed Aug 28 18:46:06 2013 +0200 +++ b/mod_lastlog/mod_lastlog.lua Wed Aug 28 18:54:00 2013 +0200 @@ -35,7 +35,19 @@ }); end); -if module:get_option_boolean("lastlog_stamp_offline") then + +if module:get_host_type() == "component" then + module:hook("message/bare", function(event) + local room = split_jid(event.stanza.attr.to); + if room then + datamanager.store(room, module.host, "lastlog", { + event = "message"; + timestamp = time(), + }); + end + end); + +elseif module:get_option_boolean("lastlog_stamp_offline") then local function offline_stamp(event) local stanza = event.stanza; local node, to_host = jid.split(stanza.attr.from);