Annotate

mod_muc_log/mod_muc_log.lua @ 5841:d3b69859553a

mod_password_policy: Change error type from 'cancel' to 'modify' This makes more sense, as the problem relates to the data that has been entered, and therefore the request could be retried with different data.
author Matthew Wild <mwild1@gmail.com>
date Mon, 08 Jan 2024 17:28:39 +0000
parent 1567:585bb8ac11bb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1148
723367b5de8c mod_muc_log: Restore copyright header that somehow got lost
Kim Alvefur <zash@zash.se>
parents: 1134
diff changeset
1 -- Copyright (C) 2009 Thilo Cestonaro
723367b5de8c mod_muc_log: Restore copyright header that somehow got lost
Kim Alvefur <zash@zash.se>
parents: 1134
diff changeset
2 -- Copyright (C) 2009 Waqas Hussain
723367b5de8c mod_muc_log: Restore copyright header that somehow got lost
Kim Alvefur <zash@zash.se>
parents: 1134
diff changeset
3 -- Copyright (C) 2009-2013 Matthew Wild
723367b5de8c mod_muc_log: Restore copyright header that somehow got lost
Kim Alvefur <zash@zash.se>
parents: 1134
diff changeset
4 -- Copyright (C) 2013 Kim Alvefur
723367b5de8c mod_muc_log: Restore copyright header that somehow got lost
Kim Alvefur <zash@zash.se>
parents: 1134
diff changeset
5 -- Copyright (C) 2013 Marco Cirillo
723367b5de8c mod_muc_log: Restore copyright header that somehow got lost
Kim Alvefur <zash@zash.se>
parents: 1134
diff changeset
6
1004
290c21a5e0ee mod_muc_log, mod_muc_log_http: cleanup syntax (off with the "~= nil"), and cut down wild table indexing.
Marco Cirillo <maranda@lightwitch.org>
parents: 976
diff changeset
7 local hosts = prosody.hosts;
976
0428009c1127 mod_muc_log: some cleanup and code refactor also force the plugin storage driver being internal.
Marco Cirillo <maranda@lightwitch.org>
parents: 103
diff changeset
8 local tostring = tostring;
1032
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
9 local split_jid = require "util.jid".split;
1134
0664f8b783fd mod_muc_log: Clean up some unused imports and variables
Kim Alvefur <zash@zash.se>
parents: 1133
diff changeset
10 local datamanager = require"core.storagemanager".olddm;
0664f8b783fd mod_muc_log: Clean up some unused imports and variables
Kim Alvefur <zash@zash.se>
parents: 1133
diff changeset
11 local data_load, data_store = datamanager.load, datamanager.store;
62
0dfd65bfedb0 mod_muc_log: using datamanager to store the logging.
Thilo Cestonaro <thilo@cestona.ro>
parents: 61
diff changeset
12 local datastore = "muc_log";
1104
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
13 local muc_form_config_option = "muc#roomconfig_enablelogging"
976
0428009c1127 mod_muc_log: some cleanup and code refactor also force the plugin storage driver being internal.
Marco Cirillo <maranda@lightwitch.org>
parents: 103
diff changeset
14
1544
814398c7139b mod_muc_log: Add option to log rooms by default unless changed in room config
Kim Alvefur <zash@zash.se>
parents: 1450
diff changeset
15 local log_by_default = module:get_option_boolean("muc_log_by_default", false);
1105
7837a5f7c10d mod_muc_log: Don't change defaults across versions!
Kim Alvefur <zash@zash.se>
parents: 1104
diff changeset
16 local log_presences = module:get_option_boolean("muc_log_presences", true);
50
a96d3f37d845 mod_muclogging: with http_server part for viewing
Thilo Cestonaro <thilo@cestona.ro>
parents: 47
diff changeset
17
976
0428009c1127 mod_muc_log: some cleanup and code refactor also force the plugin storage driver being internal.
Marco Cirillo <maranda@lightwitch.org>
parents: 103
diff changeset
18 -- Module Definitions
0428009c1127 mod_muc_log: some cleanup and code refactor also force the plugin storage driver being internal.
Marco Cirillo <maranda@lightwitch.org>
parents: 103
diff changeset
19
1450
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
20 local function get_room_from_jid(jid)
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
21 local node, host = split_jid(jid);
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
22 local component = hosts[host];
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
23 if component then
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
24 local muc = component.modules.muc
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
25 if muc and rawget(muc,"rooms") then
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
26 -- We're running 0.9.x or 0.10 (old MUC API)
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
27 return muc.rooms[jid];
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
28 elseif muc and rawget(muc,"get_room_from_jid") then
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
29 -- We're running >0.10 (new MUC API)
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
30 return muc.get_room_from_jid(jid);
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
31 else
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
32 return
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
33 end
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
34 end
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
35 end
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
36
1544
814398c7139b mod_muc_log: Add option to log rooms by default unless changed in room config
Kim Alvefur <zash@zash.se>
parents: 1450
diff changeset
37 local function logging_enabled(room)
814398c7139b mod_muc_log: Add option to log rooms by default unless changed in room config
Kim Alvefur <zash@zash.se>
parents: 1450
diff changeset
38 local enabled = room._data.logging;
814398c7139b mod_muc_log: Add option to log rooms by default unless changed in room config
Kim Alvefur <zash@zash.se>
parents: 1450
diff changeset
39 if enabled == nil then
814398c7139b mod_muc_log: Add option to log rooms by default unless changed in room config
Kim Alvefur <zash@zash.se>
parents: 1450
diff changeset
40 return log_by_default;
814398c7139b mod_muc_log: Add option to log rooms by default unless changed in room config
Kim Alvefur <zash@zash.se>
parents: 1450
diff changeset
41 end
814398c7139b mod_muc_log: Add option to log rooms by default unless changed in room config
Kim Alvefur <zash@zash.se>
parents: 1450
diff changeset
42 return enabled;
814398c7139b mod_muc_log: Add option to log rooms by default unless changed in room config
Kim Alvefur <zash@zash.se>
parents: 1450
diff changeset
43 end
814398c7139b mod_muc_log: Add option to log rooms by default unless changed in room config
Kim Alvefur <zash@zash.se>
parents: 1450
diff changeset
44
1134
0664f8b783fd mod_muc_log: Clean up some unused imports and variables
Kim Alvefur <zash@zash.se>
parents: 1133
diff changeset
45 function log_if_needed(event)
0664f8b783fd mod_muc_log: Clean up some unused imports and variables
Kim Alvefur <zash@zash.se>
parents: 1133
diff changeset
46 local stanza = event.stanza;
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1325
diff changeset
47
1450
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
48 if (stanza.name == "presence") or
61
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
49 (stanza.name == "iq") or
1450
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
50 (stanza.name == "message" and tostring(stanza.attr.type) == "groupchat")
47
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
51 then
1032
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
52 local node, host = split_jid(stanza.attr.to);
1004
290c21a5e0ee mod_muc_log, mod_muc_log_http: cleanup syntax (off with the "~= nil"), and cut down wild table indexing.
Marco Cirillo <maranda@lightwitch.org>
parents: 976
diff changeset
53 if node and host then
47
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
54 local bare = node .. "@" .. host;
1450
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
55 if get_room_from_jid(bare) then
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
56 local room = get_room_from_jid(bare)
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
57
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
58 local today = os.date("!%y%m%d");
1567
585bb8ac11bb mod_muc_log: Change to a non-locale dependent timestamp format
Kim Alvefur <zash@zash.se>
parents: 1544
diff changeset
59 local now = os.date("!%H:%M:%S");
1450
5107278268ae mod_muc_log, mod_muc_log_http: Make compatible with both new and old MUC API
Vadim Misbakh-Soloviov <mva@mva.name>
parents: 1357
diff changeset
60
1032
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
61 local muc_to = nil
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
62 local muc_from = nil;
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
63 local already_joined = false;
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1325
diff changeset
64
85
83494de806a4 mod_muc_log: Do not log other muc-component's rooms then the module was loaded for. Do neither log nor provide access to possible existing log if a room is private. (thx flo for spotting this)
Thilo Cestonaro <thilo@cestona.ro>
parents: 81
diff changeset
65 if room._data.hidden then -- do not log any data of private rooms
83494de806a4 mod_muc_log: Do not log other muc-component's rooms then the module was loaded for. Do neither log nor provide access to possible existing log if a room is private. (thx flo for spotting this)
Thilo Cestonaro <thilo@cestona.ro>
parents: 81
diff changeset
66 return;
83494de806a4 mod_muc_log: Do not log other muc-component's rooms then the module was loaded for. Do neither log nor provide access to possible existing log if a room is private. (thx flo for spotting this)
Thilo Cestonaro <thilo@cestona.ro>
parents: 81
diff changeset
67 end
1544
814398c7139b mod_muc_log: Add option to log rooms by default unless changed in room config
Kim Alvefur <zash@zash.se>
parents: 1450
diff changeset
68 if not logging_enabled(room) then -- do not log where logging is not enabled
1032
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
69 return;
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
70 end
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1325
diff changeset
71
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
72 if stanza.name == "presence" and stanza.attr.type == nil then
1032
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
73 muc_from = stanza.attr.to;
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
74 if room._occupants and room._occupants[stanza.attr.to] then
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
75 already_joined = true;
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1325
diff changeset
76 stanza:tag("alreadyJoined"):text("true");
61
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
77 end
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
78 elseif stanza.name == "iq" and stanza.attr.type == "set" then -- kick, to is the room, from is the admin, nick who is kicked is attr of iq->query->item
1004
290c21a5e0ee mod_muc_log, mod_muc_log_http: cleanup syntax (off with the "~= nil"), and cut down wild table indexing.
Marco Cirillo <maranda@lightwitch.org>
parents: 976
diff changeset
79 if stanza.tags[1] and stanza.tags[1].name == "query" then
61
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
80 local tmp = stanza.tags[1];
1004
290c21a5e0ee mod_muc_log, mod_muc_log_http: cleanup syntax (off with the "~= nil"), and cut down wild table indexing.
Marco Cirillo <maranda@lightwitch.org>
parents: 976
diff changeset
81 if tmp.tags[1] ~= nil and tmp.tags[1].name == "item" and tmp.tags[1].attr.nick then
61
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
82 tmp = tmp.tags[1];
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
83 for jid, nick in pairs(room._jid_nick) do
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
84 if nick == stanza.attr.to .. "/" .. tmp.attr.nick then
1032
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
85 muc_to = nick;
61
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
86 break;
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
87 end
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
88 end
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
89 end
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
90 end
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
91 else
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
92 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
93 if jid == stanza.attr.from then
1032
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
94 muc_from = nick;
61
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
95 break;
47
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
96 end
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
97 end
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
98 end
47
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
99
1032
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
100 if (muc_from or muc_to) then
62
0dfd65bfedb0 mod_muc_log: using datamanager to store the logging.
Thilo Cestonaro <thilo@cestona.ro>
parents: 61
diff changeset
101 local data = data_load(node, host, datastore .. "/" .. today);
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
102 local realFrom = stanza.attr.from;
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
103 local realTo = stanza.attr.to;
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1325
diff changeset
104
62
0dfd65bfedb0 mod_muc_log: using datamanager to store the logging.
Thilo Cestonaro <thilo@cestona.ro>
parents: 61
diff changeset
105 if data == nil then
0dfd65bfedb0 mod_muc_log: using datamanager to store the logging.
Thilo Cestonaro <thilo@cestona.ro>
parents: 61
diff changeset
106 data = {};
0dfd65bfedb0 mod_muc_log: using datamanager to store the logging.
Thilo Cestonaro <thilo@cestona.ro>
parents: 61
diff changeset
107 end
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1325
diff changeset
108
1032
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
109 stanza.attr.from = muc_from;
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
110 stanza.attr.to = muc_to;
62
0dfd65bfedb0 mod_muc_log: using datamanager to store the logging.
Thilo Cestonaro <thilo@cestona.ro>
parents: 61
diff changeset
111 data[#data + 1] = "<stanza time=\"".. now .. "\">" .. tostring(stanza) .. "</stanza>\n";
55
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
112 stanza.attr.from = realFrom;
d9749ed44f6e mod_muc_log: make it recognize s2s messages/presences
Thilo Cestonaro <thilo@cestona.ro>
parents: 54
diff changeset
113 stanza.attr.to = realTo;
1032
b69e5d63a4fe mod_muc_log, mod_muc_log_http: backport changes from Metronome.
Marco Cirillo <maranda@lightwitch.org>
parents: 1004
diff changeset
114 if already_joined == true then
61
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
115 if stanza[#stanza].name == "alreadyJoined" then -- normaly the faked element should be the last, remove it when it is the last
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
116 stanza[#stanza] = nil;
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
117 else
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
118 for i = 1, #stanza, 1 do
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
119 if stanza[i].name == "alreadyJoined" then -- remove the faked element
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
120 stanza[i] = nil;
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
121 break;
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
122 end
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
123 end
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
124 end
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
125 end
1357
67990f8d8228 mod_muc_log: Make sure base path is created
Kim Alvefur <zash@zash.se>
parents: 1343
diff changeset
126 datamanager.getpath(node, host, datastore, nil, true); -- create the datastore dir
62
0dfd65bfedb0 mod_muc_log: using datamanager to store the logging.
Thilo Cestonaro <thilo@cestona.ro>
parents: 61
diff changeset
127 data_store(node, host, datastore .. "/" .. today, data);
47
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
128 end
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
129 end
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
130 end
99ff520519fe mod_muclogging: initial checkin
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
131 end
61
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
132 end
e609da067e9f mod_muc_log: display room's current title; show kicked messages with and without reason
Thilo Cestonaro <thilo@cestona.ro>
parents: 60
diff changeset
133
1104
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
134 module:hook("muc-config-form", function(event)
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
135 local room, form = event.room, event.form;
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
136 table.insert(form,
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
137 {
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
138 name = muc_form_config_option,
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
139 type = "boolean",
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
140 label = "Enable Logging?",
1544
814398c7139b mod_muc_log: Add option to log rooms by default unless changed in room config
Kim Alvefur <zash@zash.se>
parents: 1450
diff changeset
141 value = logging_enabled(room),
1104
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
142 }
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
143 );
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
144 end);
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
145
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
146 module:hook("muc-config-submitted", function(event)
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
147 local room, fields, changed = event.room, event.fields, event.changed;
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
148 local new = fields[muc_form_config_option];
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
149 if new ~= room._data.logging then
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
150 room._data.logging = new;
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
151 if type(changed) == "table" then
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
152 changed[muc_form_config_option] = true;
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
153 else
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
154 event.changed = true;
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
155 end
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
156 end
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
157 end);
34c86e4d6c9d mod_muc_log: Add a room config option for logging
Kim Alvefur <zash@zash.se>
parents: 1050
diff changeset
158
1037
892272432703 mod_muc_log: Fix mistake in previous merge (thanks Maranda)
Matthew Wild <mwild1@gmail.com>
parents: 1034
diff changeset
159 module:hook("message/bare", log_if_needed, 1);
1050
a0aff903659b mod_muc_log: don't log iqs either if presences are disabled, little use and may trigger "false positives".
Marco Cirillo <maranda@lightwitch.org>
parents: 1041
diff changeset
160 if log_presences then
a0aff903659b mod_muc_log: don't log iqs either if presences are disabled, little use and may trigger "false positives".
Marco Cirillo <maranda@lightwitch.org>
parents: 1041
diff changeset
161 module:hook("iq/bare", log_if_needed, 1);
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1325
diff changeset
162 module:hook("presence/full", log_if_needed, 1);
1050
a0aff903659b mod_muc_log: don't log iqs either if presences are disabled, little use and may trigger "false positives".
Marco Cirillo <maranda@lightwitch.org>
parents: 1041
diff changeset
163 end
103
0491aa849c91 mod_muc_log: make that it logs again
Thilo Cestonaro <thilo@cestona.ro>
parents: 94
diff changeset
164
94
941fd7d8b9b2 mod_muc_log: split into mod_muc_log and mod_muc_log_http
Thilo Cestonaro <thilo@cestona.ro>
parents: 90
diff changeset
165 module:log("debug", "module mod_muc_log loaded!");