mod_firewall: Update user marks to store instantly via map store
The original approach was to keep marks in memory only, and persist them at
shutdown. That saves I/O, at the cost of potentially losing marks on an
unclean shutdown.
This change persists marks instantly, which may have some performance overhead
but should be more "correct".
It also splits the marking/unmarking into an event which may be watched or
even fired by other modules.
module:hook("muc-occupant-joined", function (event)
local room = event.room;
local occupant_jid = event.occupant.bare_jid;
local aff = room:get_affiliation(occupant_jid);
if aff then return; end -- user already registered
module:log("debug", "Automatically registering %s as a member in %s", occupant_jid, room.jid);
room:set_affiliation(true, occupant_jid, "member");
end);