comparison mod_firewall/marks.lib.lua @ 6557:2d916ba3253c

mod_firewall: marks: Fix shell commands
author Matthew Wild <mwild1@gmail.com>
date Sun, 24 May 2026 20:04:03 +0100
parents f9d93d7cd6d5
children
comparison
equal deleted inserted replaced
6556:7477e97a9045 6557:2d916ba3253c
1 local jid = require "prosody.util.jid";
2
1 local mark_storage = module:open_store("firewall_marks", "keyval+"); 3 local mark_storage = module:open_store("firewall_marks", "keyval+");
2 4
3 local user_sessions = prosody.hosts[module.host].sessions; 5 local user_sessions = prosody.hosts[module.host].sessions;
4 6
5 module:hook("resource-bind", function (event) 7 module:hook("resource-bind", function (event)
56 { name = "mark_name", type = "string" }; 58 { name = "mark_name", type = "string" };
57 }; 59 };
58 host_selector = "user_jid"; 60 host_selector = "user_jid";
59 handler = function(self, user_jid, mark_name) --luacheck: ignore 212/self 212/host 61 handler = function(self, user_jid, mark_name) --luacheck: ignore 212/self 212/host
60 local username, host = jid.split(user_jid); 62 local username, host = jid.split(user_jid);
61 if not username or not hosts[host] then 63 if not username or not prosody.hosts[host] then
62 return nil, "Invalid JID supplied"; 64 return nil, "Invalid JID supplied";
63 elseif not idsafe(mark_name) then 65 elseif not idsafe(mark_name) then
64 return nil, "Invalid characters in mark name"; 66 return nil, "Invalid characters in mark name";
65 end 67 end
66 if not module:fire_event("firewall/marked/user", { 68 if not module:fire_event("firewall/marked/user", {
123 end 125 end
124 table.sort(usernames, function (a, b) 126 table.sort(usernames, function (a, b)
125 return users[a] < users[b]; 127 return users[a] < users[b];
126 end); 128 end);
127 for _, username in ipairs(usernames) do 129 for _, username in ipairs(usernames) do
128 self.session.print(username, os.date("%Y-%m-%d %R:%s", users[username]); 130 self.session.print(username, os.date("%Y-%m-%d %R:%s", users[username]));
129 end 131 end
130 return true, ("Showing %d users"):format(#usernames); 132 return true, ("Showing %d users"):format(#usernames);
131 end; 133 end;
132 }); 134 });
133 135