Annotate

mod_muc_log/mod_muc_log.lua @ 59:50e3d5b87119

mod_muc_log: better presence and message parsing; react on subject changes
author Thilo Cestonaro <thilo@cestona.ro>
date Tue, 20 Oct 2009 23:25:21 +0200
parent 57:cddcea7c091a
child 60:5cca708c9f11
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
1 -- Copyright (C) 2009 Thilo Cestonaro
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
2 --
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
3 -- This project is MIT/X11 licensed. Please see the
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
4 -- COPYING file in the source package for more information.
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
5 --
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
6 local prosody = prosody;
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
7 local splitJid = require "util.jid".split;
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
8 local bareJid = require "util.jid".bare;
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
9 local config_get = require "core.configmanager".get;
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
10 local httpserver = require "net.httpserver";
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
11 local serialize = require "util.serialization".serialize;
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
12 local config = {};
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
13
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
14
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
15 --[[ LuaFileSystem
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
16 * URL: http://www.keplerproject.org/luafilesystem/index.html
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
17 * Install: luarocks install luafilesystem
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
18 * ]]
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
19 local lfs = require "lfs";
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
20
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
21 local lom = require "lxp.lom";
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
22
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
23
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
24 --[[
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
25 * Default templates for the html output.
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
26 ]]--
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
27 local html = {};
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
28 html.doc = [[<html>
57
cddcea7c091a mod_muc_log: set content-type header; escape some html stuff in messages (>, <, \n, http://....)
Thilo Cestonaro <thilo@cestona.ro>
parents: 56
diff changeset
29 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
30 <head>
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
31 <title>muc_log</title>
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
32 </head>
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
33 <style type="text/css">
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
34 <!--
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
35 .timestuff {color: #AAAAAA; text-decoration: none;}
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
36 .muc_join {color: #009900; font-style: italic;}
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
37 .muc_leave {color: #009900; font-style: italic;}
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
38 .muc_statusChange {color: #009900; font-style: italic;}
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
39 .muc_title {color: #009900;}
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
40 .muc_titlenick {color: #009900; font-style: italic;}
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
41 .muc_kick {color: #009900; font-style: italic;}
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
42 .muc_bann {color: #009900; font-style: italic;}
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
43 .muc_name {color: #0000AA;}
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
44 //-->
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
45 </style>
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
46 <body>
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
47 ###BODY_STUFF###
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
48 </body>
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
49 </html>]];
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
50
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
51 html.hosts = {};
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
52 html.hosts.bit = [[<a href="/muc_log/###JID###">###JID###</a><br />]]
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
53 html.hosts.body = [[<h2>Rooms hosted on this server:</h2><hr /><p>
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
54 ###HOSTS_STUFF###
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
55 </p><hr />]];
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
57 html.days = {};
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
58 html.days.bit = [[<a href="/muc_log/###JID###/?year=###YEAR###&month=###MONTH###&day=###DAY###">20###YEAR###/###MONTH###/###DAY###</a><br />]];
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
59 html.days.body = [[<h2>available logged days of room: ###JID###</h2><hr /><p>
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
60 ###DAYS_STUFF###
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
61 </p><hr />]];
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
62
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
63 html.day = {};
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
64 html.day.time = [[<a name="###TIME###" href="####TIME###" class="timestuff">[###TIME###]</a> ]]; -- the one ####TIME### need to stay! it will evaluate to e.g. #09:10:56 which is an anker then
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
65 html.day.presence = {};
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
66 html.day.presence.join = [[###TIME_STUFF###<font class="muc_join"> *** ###NICK### joins the room</font><br />]];
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
67 html.day.presence.leave = [[###TIME_STUFF###<font class="muc_leave"> *** ###NICK### leaves the room</font><br />]];
59
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
68 html.day.presence.statusText = [[ and his status message is "###STATUS###"]];
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
69 html.day.presence.statusChange = [[###TIME_STUFF###<font class="muc_statusChange"> *** ###NICK### shows now as "###SHOW###"###STATUS_STUFF###</font><br />]];
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
70 html.day.message = [[###TIME_STUFF###<font class="muc_name">&lt;###NICK###&gt;</font> ###MSG###<br />]];
59
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
71 html.day.titleChange = [[###TIME_STUFF###<font class="muc_titlenick"> *** ###NICK### changed the title to</font> <font class="muc_title">"###TITLE###"</font><br />]];
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
72 html.day.kick = [[###TIME_STUFF###<font class="muc_titlenick"> *** ###NICK### kicked ###VICTIM###</font><br />]];
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
73 html.day.bann = [[###TIME_STUFF###<font class="muc_titlenick"> *** ###NICK### banned ###VICTIM###</font><br />]];
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
74 html.day.body = [[<h2>room ###JID### logging of 20###YEAR###/###MONTH###/###DAY###</h2><hr /><p>
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
75 ###DAY_STUFF###
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
76 </p><hr />]];
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
77
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
78 html.help = [[
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
79 MUC logging is not configured correctly.<br />
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
80 Here is a example config:<br />
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
81 Component "rooms.example.com" "muc"<br />
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
82 &nbsp;&nbsp;modules_enabled = {<br />
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
83 &nbsp;&nbsp;&nbsp;&nbsp;"muc_log";<br />
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
84 &nbsp;&nbsp;}<br />
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
85 &nbsp;&nbsp;muc_log = {<br />
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
86 &nbsp;&nbsp;&nbsp;&nbsp;folder = "/opt/local/var/log/prosody/rooms";<br />
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
87 &nbsp;&nbsp;&nbsp;&nbsp;http_port = "/opt/local/var/log/prosody/rooms";<br />
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
88 &nbsp;&nbsp;}<br />
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
89 ]];
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
90
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
91 function validateLogFolder()
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
92 if config.folder == nil then
52
11d1d4ff8037 mod_muclogging: renamed to mod_muc_log; s/muclogging/muc_log/
Thilo Cestonaro <thilo@cestona.ro>
parents: 51
diff changeset
93 module:log("warn", "muc_log folder isn't configured. configure it please!");
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
94 return false;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
95 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
96
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
97 -- check existance
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
98 local attributes = lfs.attributes(config.folder);
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
99 if attributes == nil then
52
11d1d4ff8037 mod_muclogging: renamed to mod_muc_log; s/muclogging/muc_log/
Thilo Cestonaro <thilo@cestona.ro>
parents: 51
diff changeset
100 module:log("warn", "muc_log folder doesn't exist. create it please!");
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
101 return false;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
102 elseif attributes.mode ~= "directory" then
52
11d1d4ff8037 mod_muclogging: renamed to mod_muc_log; s/muclogging/muc_log/
Thilo Cestonaro <thilo@cestona.ro>
parents: 51
diff changeset
103 module:log("warn", "muc_log folder isn't a folder, it's a %s. change this please!", attributes.mode);
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
104 return false;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
105 end --TODO: check for write rights!
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
106
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
107 return true;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
108 end
47
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
109
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
110 function logIfNeeded(e)
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
111 local stanza, origin = e.stanza, e.origin;
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
112 if validateLogFolder() == false then
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
113 return;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
114 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
115
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
116 if (stanza.name == "presence") or
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
117 (stanza.name == "message" and tostring(stanza.attr.type) == "groupchat")
47
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
118 then
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
119 local node, host, resource = splitJid(stanza.attr.to);
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
120 if node ~= nil and host ~= nil then
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
121 local bare = node .. "@" .. host;
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
122 if prosody.hosts[host] ~= nil and prosody.hosts[host].muc ~= nil and prosody.hosts[host].muc.rooms[bare] ~= nil then
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
123 local room = prosody.hosts[host].muc.rooms[bare]
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
124 local today = os.date("%y%m%d");
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
125 local now = os.date("%X")
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
126 local fn = config.folder .. "/" .. today .. "_" .. bare .. ".log";
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
127 local mucFrom = nil;
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
128
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
129 if stanza.name == "presence" and stanza.attr.type == nil then
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
130 mucFrom = stanza.attr.to;
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
131 else
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
132 for jid, nick in pairs(room._jid_nick) do
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
133 if jid == stanza.attr.from then
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
134 mucFrom = nick;
47
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
135 end
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
136 end
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
137 end
47
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
138
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
139 if mucFrom ~= nil then
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
140 module:log("debug", "try to open room log: %s", fn);
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
141 local f = assert(io.open(fn, "a"));
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
142 local realFrom = stanza.attr.from;
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
143 local realTo = stanza.attr.to;
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
144 stanza.attr.from = mucFrom;
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
145 stanza.attr.to = nil;
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
146 f:write("<stanza time=\"".. now .. "\">" .. tostring(stanza) .. "</stanza>\n");
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
147 stanza.attr.from = realFrom;
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
148 stanza.attr.to = realTo;
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
149 f:close()
47
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
150 end
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
151 end
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
152 end
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
153 end
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
154 return;
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
155 end
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
156
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
157 function createDoc(body)
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
158 return html.doc:gsub("###BODY_STUFF###", body);
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
159 end
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
160
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
161 local function htmlEscape(t)
57
cddcea7c091a mod_muc_log: set content-type header; escape some html stuff in messages (>, <, \n, http://....)
Thilo Cestonaro <thilo@cestona.ro>
parents: 56
diff changeset
162 t = t:gsub("<", "&lt;");
cddcea7c091a mod_muc_log: set content-type header; escape some html stuff in messages (>, <, \n, http://....)
Thilo Cestonaro <thilo@cestona.ro>
parents: 56
diff changeset
163 t = t:gsub(">", "&gt;");
cddcea7c091a mod_muc_log: set content-type header; escape some html stuff in messages (>, <, \n, http://....)
Thilo Cestonaro <thilo@cestona.ro>
parents: 56
diff changeset
164 t = t:gsub("(http://[%a%d@%.:/&%?=%-_#]+)", [[<a href="%1">%1</a>]]);
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
165 t = t:gsub("\n", "<br />");
57
cddcea7c091a mod_muc_log: set content-type header; escape some html stuff in messages (>, <, \n, http://....)
Thilo Cestonaro <thilo@cestona.ro>
parents: 56
diff changeset
166 -- TODO do any html escaping stuff ...
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
167 return t;
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
168 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
169
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
170 function splitQuery(query)
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
171 local ret = {};
59
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
172 local name, value = nil, nil;
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
173 if query == nil then return ret; end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
174 local last = 1;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
175 local idx = query:find("&", last);
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
176 while idx ~= nil do
59
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
177 name, value = query:sub(last, idx - 1):match("^(%a+)=(%d+)$");
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
178 ret[name] = value;
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
179 last = idx + 1;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
180 idx = query:find("&", last);
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
181 end
59
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
182 name, value = query:sub(last):match("^(%a+)=(%d+)$");
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
183 ret[name] = value;
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
184 return ret;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
185 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
186
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
187 function grepRoomJid(url)
52
11d1d4ff8037 mod_muclogging: renamed to mod_muc_log; s/muclogging/muc_log/
Thilo Cestonaro <thilo@cestona.ro>
parents: 51
diff changeset
188 local tmp = url:sub(string.len("/muc_log/") + 1);
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
189 local node = nil;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
190 local host = nil;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
191 local at = nil;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
192 local slash = nil;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
193
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
194 at = tmp:find("@");
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
195 slash = tmp:find("/");
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
196 if slash ~= nil then
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
197 slash = slash - 1;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
198 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
199
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
200 if at ~= nil then
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
201 node = tmp:sub(1, at - 1);
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
202 host = tmp:sub(at + 1, slash);
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
203 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
204 return node, host;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
205 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
206
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
207 local function generateRoomListSiteContent()
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
208 local rooms = "";
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
209 for host, config in pairs(prosody.hosts) do
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
210 if prosody.hosts[host].muc ~= nil then
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
211 for jid, room in pairs(prosody.hosts[host].muc.rooms) do
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
212 rooms = rooms .. html.hosts.bit:gsub("###JID###", jid);
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
213 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
214 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
215 end
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
216
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
217 return html.hosts.body:gsub("###HOSTS_STUFF###", rooms);
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
218 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
219
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
220 local function generateDayListSiteContentByRoom(bareRoomJid)
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
221 local days = "";
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
222 local tmp;
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
223
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
224 for file in lfs.dir(config.folder) do
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
225 local year, month, day = file:match("^(%d%d)(%d%d)(%d%d)_" .. bareRoomJid .. ".log");
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
226 if year ~= nil and month ~= nil and day ~= nil and
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
227 year ~= "" and month ~= "" and day ~= ""
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
228 then
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
229 tmp = html.days.bit;
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
230 tmp = tmp:gsub("###JID###", bareRoomJid);
59
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
231 tmp = tmp:gsub("###YEAR###", year):gsub("###MONTH###", month):gsub("###DAY###", day);
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
232 days = tmp .. days;
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
233 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
234 end
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
235 if days ~= "" then
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
236 tmp = html.days.body:gsub("###DAYS_STUFF###", days);
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
237 return tmp:gsub("###JID###", bareRoomJid);
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
238 else
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
239 return generateRoomListSiteContent(); -- fallback
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
240 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
241 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
242
59
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
243 local function parsePresenceStanza(stanza, timeStuff, nick)
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
244 local ret = "";
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
245 -- module:log("debug", serialize(stanza));
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
246 if stanza[1].attr.type == nil then
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
247 local show, status = nil, "";
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
248 for _, tag in ipairs(stanza[1]) do
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
249 module:log("debug", serialize(tag));
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
250 if tag.tag == "show" then
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
251 show = tag[1];
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
252 elseif tag.tag == "status" then
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
253 status = tag[1];
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
254 end
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
255 end
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
256 if show ~= nil then
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
257 ret = html.day.presence.statusChange:gsub("###TIME_STUFF###", timeStuff);
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
258 if status ~= "" then
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
259 status = html.day.presence.statusText:gsub("###STATUS###", status);
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
260 end
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
261 ret = ret:gsub("###SHOW###", show):gsub("###NICK###", nick):gsub("###STATUS_STUFF###", status);
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
262 else
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
263 ret = html.day.presence.join:gsub("###TIME_STUFF###", timeStuff):gsub("###NICK###", nick);
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
264 end
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
265 elseif stanza[1].attr.type ~= nil and stanza[1].attr.type == "unavailable" then
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
266 ret = html.day.presence.leave:gsub("###TIME_STUFF###", timeStuff):gsub("###NICK###", nick);
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
267 end
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
268 return ret;
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
269 end
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
270
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
271 local function parseMessageStanza(stanza, timeStuff, nick)
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
272 local body, title, ret = nil, nil, "";
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
273
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
274 for _,tag in ipairs(stanza[1]) do
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
275 if tag.tag == "body" then
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
276 body = tag[1];
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
277 if nick ~= nil then
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
278 break;
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
279 end
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
280 elseif tag.tag == "nick" and nick == nil then
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
281 nick = tag[1];
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
282 if body ~= nil or title ~= nil then
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
283 break;
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
284 end
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
285 elseif tag.tag == "subject" then
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
286 title = tag[1];
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
287 if nick ~= nil then
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
288 break;
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
289 end
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
290 end
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
291 end
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
292 if nick ~= nil and body ~= nil then
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
293 body = htmlEscape(body);
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
294 ret = html.day.message:gsub("###TIME_STUFF###", timeStuff):gsub("###NICK###", nick):gsub("###MSG###", body);
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
295 elseif nick ~= nil and title ~= nil then
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
296 title = htmlEscape(title);
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
297 ret = html.day.titleChange:gsub("###TIME_STUFF###", timeStuff):gsub("###NICK###", nick):gsub("###TITLE###", title);
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
298 end
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
299 return ret;
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
300 end
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
301
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
302 local function parseDay(bareRoomJid, query)
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
303 local ret = "";
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
304 local year;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
305 local month;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
306 local day;
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
307 local tmp;
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
308
59
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
309 if query.year ~= nil and query.month ~= nil and query.day ~= nil then
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
310 local file = config.folder .. "/" .. query.year .. query.month .. query.day .. "_" .. bareRoomJid .. ".log";
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
311 local f, err = io.open(file, "r");
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
312 if f ~= nil then
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
313 local content = f:read("*a");
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
314 local parsed = lom.parse("<xml>" .. content .. "</xml>");
59
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
315 f:close();
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
316 if parsed ~= nil then
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
317 for _,stanza in ipairs(parsed) do
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
318 if stanza.attr ~= nil and stanza.attr.time ~= nil then
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
319 local timeStuff = html.day.time:gsub("###TIME###", stanza.attr.time);
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
320 if stanza[1] ~= nil then
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
321 local nick;
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
322
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
323 -- grep nick from "from" resource
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
324 if stanza[1].attr.from ~= nil then
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
325 nick = stanza[1].attr.from:match("/(.+)$");
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
326 end
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
327
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
328 if stanza[1].tag == "presence" and nick ~= nil then
59
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
329 ret = ret .. parsePresenceStanza(stanza, timeStuff, nick);
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
330 elseif stanza[1].tag == "message" then
59
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
331 ret = ret .. parseMessageStanza(stanza, timeStuff, nick);
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
332 else
59
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
333 module:log("info", "unknown stanza subtag in log found. room: %s; day: %s", bareRoomJid, query.year .. "/" .. query.month .. "/" .. query.day);
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
334 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
335 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
336 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
337 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
338 else
59
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
339 module:log("warn", "could not parse room log. room: %s; day: %s", bareRoomJid, query.year .. "/" .. query.month .. "/" .. query.day);
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
340 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
341 else
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
342 ret = err;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
343 end
59
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
344 tmp = html.day.body:gsub("###DAY_STUFF###", ret):gsub("###JID###", bareRoomJid);
50e3d5b87119 mod_muc_log: better presence and message parsing; react on subject changes
Thilo Cestonaro <thilo@cestona.ro>
parents: 57
diff changeset
345 tmp = tmp:gsub("###YEAR###", query.year):gsub("###MONTH###", query.month):gsub("###DAY###", query.day);
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
346 return tmp;
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
347 else
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
348 return generateDayListSiteContentByRoom(bareRoomJid); -- fallback
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
349 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
350 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
351
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
352 function handle_request(method, body, request)
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
353 module:log("debug", "got a request ...")
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
354 local query = splitQuery(request.url.query);
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
355 local node, host = grepRoomJid(request.url.path);
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
356
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
357 if validateLogFolder() == false then
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
358 return createDoc(html.help);
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
359 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
360 if node ~= nil and host ~= nil then
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
361 local bare = node .. "@" .. host;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
362 if prosody.hosts[host] ~= nil and prosody.hosts[host].muc ~= nil and prosody.hosts[host].muc.rooms[bare] ~= nil then
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
363 local room = prosody.hosts[host].muc.rooms[bare];
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
364 if request.url.query == nil then
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
365 return createDoc(generateDayListSiteContentByRoom(bare));
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
366 else
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
367 return createDoc(parseDay(bare, query));
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
368 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
369 else
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
370 module:log("warn", "room instance not found. bare room jid: %s", tostring(bare));
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
371 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
372 else
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
373 return createDoc(generateRoomListSiteContent());
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
374 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
375 return;
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
376 end
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
377
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
378 config = config_get(module:get_host(), "core", "muc_log");
56
e9de45beaf5e mod_muc_log: templify the html stuff
Thilo Cestonaro <thilo@cestona.ro>
parents: 55
diff changeset
379 module:log("debug", serialize(config));
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
380
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
381 httpserver.new_from_config({ config.http_port or true }, handle_request, { base = "muc_log" });
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
382
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
383 module:hook("message/bare", logIfNeeded, 500);
47
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
384 module:hook("pre-message/bare", logIfNeeded, 500);
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
385 module:hook("presence/full", logIfNeeded, 500);
47
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
386 module:hook("pre-presence/full", logIfNeeded, 500);