--- a/mod_firewall/conditions.lib.lua Mon Dec 11 19:09:25 2023 +0000
+++ b/mod_firewall/conditions.lib.lua Tue Dec 12 19:06:37 2023 +0000
@@ -205,11 +205,11 @@
end
function condition_handlers.TO_ROLE(role_name)
- return ("get_jid_role(bare_to, current_host).name == %q"):format(role_name), { "get_jid_role", "current_host", "bare_to" };
+ return ("recipient_role and recipient_role.name == %q"):format(role_name), { "recipient_role" };
end
function condition_handlers.FROM_ROLE(role_name)
- return ("get_jid_role(bare_from, current_host).name == %q"):format(role_name), { "get_jid_role", "current_host", "bare_from" };
+ return ("sender_role and sender_role.name == %q"):format(role_name), { "sender_role" };
end
local day_numbers = { sun = 0, mon = 2, tue = 3, wed = 4, thu = 5, fri = 6, sat = 7 };
--- a/mod_firewall/mod_firewall.lua Mon Dec 11 19:09:25 2023 +0000
+++ b/mod_firewall/mod_firewall.lua Tue Dec 12 19:06:37 2023 +0000
@@ -261,6 +261,14 @@
return code, { "search:"..search_name, "pattern:"..pattern_name };
end;
};
+ sender_role = {
+ local_code = [[local sender_role = get_jid_role(bare_from, current_host)]];
+ depends = { "bare_from", "current_host", "get_jid_role" };
+ };
+ recipient_role = {
+ local_code = [[local recipient_role = get_jid_role(bare_to, current_host)]];
+ depends = { "bare_to", "current_host", "get_jid_role" };
+ };
scan_list = {
global_code = [[local function scan_list(list, items) for item in pairs(items) do if list:contains(item) then return true; end end end]];
};