comparison mod_firewall/marks.lib.lua @ 6548:430584888704

mod_firewall: marks: load marks from storage on login
author Matthew Wild <mwild1@gmail.com>
date Sun, 24 May 2026 10:48:24 +0100
parents 048284447643
children d2e50b587721
comparison
equal deleted inserted replaced
6547:cfcd2d2f7119 6548:430584888704
1 local mark_storage = module:open_store("firewall_marks"); 1 local mark_storage = module:open_store("firewall_marks");
2 local mark_map_storage = module:open_store("firewall_marks", "map"); 2 local mark_map_storage = module:open_store("firewall_marks", "map");
3 3
4 local user_sessions = prosody.hosts[module.host].sessions; 4 local user_sessions = prosody.hosts[module.host].sessions;
5
6 module:hook("resource-bind", function (event)
7 local session = event.session;
8 local username = session.username;
9 local user = user_sessions[username];
10 local marks = user.firewall_marks;
11 if not marks then
12 marks = mark_storage:get(username) or {};
13 user.firewall_marks = marks; -- luacheck: ignore 122
14 end
15 session.firewall_marks = marks;
16 end);
17
5 18
6 module:hook("firewall/marked/user", function (event) 19 module:hook("firewall/marked/user", function (event)
7 local user = user_sessions[event.username]; 20 local user = user_sessions[event.username];
8 local marks = user and user.firewall_marks; 21 local marks = user and user.firewall_marks;
9 if user and not marks then 22 if user and not marks then