|
@@ -1,8 +1,6 @@
|
1
|
1
|
-- Maps MUC JIDs like room1@muc.foo.example.com to JIDs like [foo]room1@muc.example.com
|
2
|
2
|
-- Must be loaded on the client host in Prosody
|
3
|
3
|
|
4
|
|
-module:set_global();
|
5
|
|
-
|
6
|
4
|
-- It is recommended to set muc_mapper_domain_base to the main domain being served (example.com)
|
7
|
5
|
|
8
|
6
|
local jid = require "util.jid";
|
|
@@ -13,7 +11,7 @@ local muc_domain_prefix = module:get_option_string("muc_mapper_domain_prefix", "
|
13
|
11
|
|
14
|
12
|
local muc_domain_base = module:get_option_string("muc_mapper_domain_base");
|
15
|
13
|
if not muc_domain_base then
|
16
|
|
- module:log("warn", "No 'muc_domain_base' option set, disabling muc_mapper plugin inactive");
|
|
14
|
+ module:log("warn", "No 'muc_mapper_domain_base' option set, disabling muc_mapper plugin inactive");
|
17
|
15
|
return
|
18
|
16
|
end
|
19
|
17
|
|
|
@@ -116,14 +114,14 @@ end
|
116
|
114
|
function module.load()
|
117
|
115
|
if module.reloading then
|
118
|
116
|
module:log("debug", "Reloading MUC mapper!");
|
119
|
|
- else
|
|
117
|
+ else
|
120
|
118
|
module:log("debug", "First load of MUC mapper!");
|
121
|
119
|
end
|
122
|
120
|
filters.add_filter_hook(filter_session);
|
123
|
121
|
end
|
124
|
122
|
|
125
|
123
|
function module.unload()
|
126
|
|
- filters.remove_filter_hook(filter_session);
|
|
124
|
+ filters.remove_filter_hook(filter_session);
|
127
|
125
|
end
|
128
|
126
|
|
129
|
127
|
|
|
@@ -150,10 +148,14 @@ local function hook_all_stanzas(handler, host_module, event_prefix)
|
150
|
148
|
end
|
151
|
149
|
end
|
152
|
150
|
|
153
|
|
-
|
154
|
|
-function module.add_host(host_module)
|
155
|
|
- module:log("info",
|
156
|
|
- "Loading mod_muc_domain_mapper for host %s!", host_module.host);
|
|
151
|
+function add_host(host)
|
|
152
|
+ module:log("info", "Loading mod_muc_domain_mapper for host %s!", host);
|
|
153
|
+ local host_module = module:context(host);
|
157
|
154
|
hook_all_stanzas(incoming_stanza_rewriter, host_module);
|
158
|
155
|
hook_all_stanzas(outgoing_stanza_rewriter, host_module, "pre-");
|
159
|
156
|
end
|
|
157
|
+
|
|
158
|
+prosody.events.add_handler("host-activated", add_host);
|
|
159
|
+for host in pairs(prosody.hosts) do
|
|
160
|
+ add_host(host);
|
|
161
|
+end
|