Diff

mod_muc_limits/mod_muc_limits.lua @ 1042:5fd0860c86cd

mod_muc_limits: Allow stanzas from affiliated users even if they are not in the room
author Matthew Wild <mwild1@gmail.com>
date Mon, 03 Jun 2013 08:36:00 +0100
parent 1040:6574303a8169
child 1057:0b41122b19f9
line wrap: on
line diff
--- a/mod_muc_limits/mod_muc_limits.lua	Sun Jun 02 02:32:21 2013 +0200
+++ b/mod_muc_limits/mod_muc_limits.lua	Mon Jun 03 08:36:00 2013 +0100
@@ -1,8 +1,9 @@
 
-local jid = require "util.jid";
+local jid_split, jid_bare = require "util.jid".split, require "util.jid".bare;
 local st = require "util.stanza";
 local new_throttle = require "util.throttle".create;
 local t_insert, t_concat = table.insert, table.concat;
+local hosts = prosody.hosts;
 
 local xmlns_muc = "http://jabber.org/protocol/muc";
 
@@ -24,12 +25,12 @@
 	if stanza.name == "presence" and stanza.attr.type == "unavailable" then -- Don't limit room leaving
 		return;
 	end
-	local dest_room, dest_host, dest_nick = jid.split(stanza.attr.to);
+	local dest_room, dest_host, dest_nick = jid_split(stanza.attr.to);
 	local room = hosts[module.host].modules.muc.rooms[dest_room.."@"..dest_host];
 	if not room then return; end
 	local from_jid = stanza.attr.from;
 	local occupant = room._occupants[room._jid_nick[from_jid]];
-	if occupant and occupant.affiliation then
+	if (occupant and occupant.affiliation) or (not(occupant) and room._affiliations[jid_bare(from_jid)]) then
 		module:log("debug", "Skipping stanza from affiliated user...");
 		return;
 	elseif max_nick_length and stanza.name == "presence" and not room._occupants[stanza.attr.to] and #dest_nick > max_nick_length then