diff mod_muc_limits/mod_muc_limits.lua @ 3188:5c3f3f5a4377

Backed out parts of changeset a81456a13797
author Kim Alvefur <zash@zash.se>
date Wed, 18 Jul 2018 15:57:13 +0200
parents a81456a13797
children 6a3060d5e85d
line wrap: on
line diff
--- a/mod_muc_limits/mod_muc_limits.lua	Fri Jul 13 14:38:40 2018 +0200
+++ b/mod_muc_limits/mod_muc_limits.lua	Wed Jul 18 15:57:13 2018 +0200
@@ -25,18 +25,6 @@
 	dropped_jids = nil;
 end
 
-local function get_non_outcast_affiliations(room)
-	local nmembers = 0;
-	-- this is an evil hack, we probably should not access _affiliations
-	-- directly ...
-	for _, aff in pairs(room._affiliations) do
-		if aff ~= "outcast" then
-			nmembers = nmembers + 1;
-		end
-	end
-	return nmembers;
-end
-
 local function handle_stanza(event)
 	local origin, stanza = event.origin, event.stanza;
 	if stanza.name == "presence" and stanza.attr.type == "unavailable" then -- Don't limit room leaving
@@ -61,15 +49,7 @@
 		throttle = new_throttle(period*burst, burst);
 		room.throttle = throttle;
 	end
-
-	local cost = 1;
-	-- we scale the cost by the inverse of the square root of the number of
-	-- members; this should effectively raise the limit by a factor of
-	-- sqrt(nmembers)
-	local nmembers = math.max(get_non_outcast_affiliations(room), 1);
-	cost = cost / math.sqrt(nmembers);
-
-	if not throttle:poll(cost) then
+	if not throttle:poll(1) then
 		module:log("debug", "Dropping stanza for %s@%s from %s, over rate limit", dest_room, dest_host, from_jid);
 		if not dropped_jids then
 			dropped_jids = { [from_jid] = true, from_jid };