Mercurial > prosody-modules
comparison mod_muc_limits/mod_muc_limits.lua @ 3968:bf5d91769f99
Merge commit
| author | tmolitor <thilo@eightysoft.de> |
|---|---|
| date | Sun, 05 Apr 2020 23:39:08 +0200 |
| parents | 2b10e51d85a6 |
| children | 731ba9400c10 |
comparison
equal
deleted
inserted
replaced
| 3967:0957ba6aeb99 | 3968:bf5d91769f99 |
|---|---|
| 11 | 11 |
| 12 local period = math.max(module:get_option_number("muc_event_rate", 0.5), 0); | 12 local period = math.max(module:get_option_number("muc_event_rate", 0.5), 0); |
| 13 local burst = math.max(module:get_option_number("muc_burst_factor", 6), 1); | 13 local burst = math.max(module:get_option_number("muc_burst_factor", 6), 1); |
| 14 | 14 |
| 15 local max_nick_length = module:get_option_number("muc_max_nick_length", 23); -- Default chosen through scientific methods | 15 local max_nick_length = module:get_option_number("muc_max_nick_length", 23); -- Default chosen through scientific methods |
| 16 local join_only = module:get_option_boolean("muc_limit_joins_only", false); | |
| 16 local dropped_count = 0; | 17 local dropped_count = 0; |
| 17 local dropped_jids; | 18 local dropped_jids; |
| 18 | 19 |
| 19 local function log_dropped() | 20 local function log_dropped() |
| 20 module:log("warn", "Dropped %d stanzas from %d JIDs: %s", dropped_count, #dropped_jids, t_concat(dropped_jids, ", ")); | 21 module:log("warn", "Dropped %d stanzas from %d JIDs: %s", dropped_count, #dropped_jids, t_concat(dropped_jids, ", ")); |
| 72 end | 73 end |
| 73 end | 74 end |
| 74 | 75 |
| 75 if rooms then | 76 if rooms then |
| 76 function module.unload() | 77 function module.unload() |
| 77 for room_jid, room in pairs(rooms) do | 78 for room_jid, room in pairs(rooms) do --luacheck: ignore 213/room_jid |
| 78 room.throttle = nil; | 79 room.throttle = nil; |
| 79 end | 80 end |
| 80 end | 81 end |
| 81 | 82 |
| 82 module:hook("message/bare", handle_stanza, 501); | |
| 83 module:hook("message/full", handle_stanza, 501); | |
| 84 module:hook("presence/bare", handle_stanza, 501); | |
| 85 module:hook("presence/full", handle_stanza, 501); | 83 module:hook("presence/full", handle_stanza, 501); |
| 84 if not join_only then | |
| 85 module:hook("message/bare", handle_stanza, 501); | |
| 86 module:hook("message/full", handle_stanza, 501); | |
| 87 module:hook("presence/bare", handle_stanza, 501); | |
| 88 end | |
| 86 else | 89 else |
| 87 module:hook("muc-occupant-pre-join", handle_stanza); | 90 module:hook("muc-occupant-pre-join", handle_stanza); |
| 88 module:hook("muc-occupant-pre-change", handle_stanza); | 91 if not join_only then |
| 89 module:hook("muc-occupant-groupchat", handle_stanza); | 92 module:hook("muc-occupant-pre-change", handle_stanza); |
| 93 module:hook("muc-occupant-groupchat", handle_stanza); | |
| 94 end | |
| 90 end | 95 end |
