comparison mod_lastlog/mod_lastlog.lua @ 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
parents 8999967fc4fe
children 9eac4e2386d2
comparison
equal deleted inserted replaced
1173:8999967fc4fe 1174:bd7901fef71b
33 timestamp = time(), 33 timestamp = time(),
34 ip = log_ip and session.ip or nil, 34 ip = log_ip and session.ip or nil,
35 }); 35 });
36 end); 36 end);
37 37
38 if module:get_option_boolean("lastlog_stamp_offline") then 38
39 if module:get_host_type() == "component" then
40 module:hook("message/bare", function(event)
41 local room = split_jid(event.stanza.attr.to);
42 if room then
43 datamanager.store(room, module.host, "lastlog", {
44 event = "message";
45 timestamp = time(),
46 });
47 end
48 end);
49
50 elseif module:get_option_boolean("lastlog_stamp_offline") then
39 local function offline_stamp(event) 51 local function offline_stamp(event)
40 local stanza = event.stanza; 52 local stanza = event.stanza;
41 local node, to_host = jid.split(stanza.attr.from); 53 local node, to_host = jid.split(stanza.attr.from);
42 if to_host == host and event.origin == hosts[host] and stanza.attr.type == "unavailable" then 54 if to_host == host and event.origin == hosts[host] and stanza.attr.type == "unavailable" then
43 local data = datamanager.load(node, host, "lastlog"); 55 local data = datamanager.load(node, host, "lastlog");