Skip to content

Instantly share code, notes, and snippets.

@zeen
Created December 13, 2010 20:57
Show Gist options
  • Save zeen/739591 to your computer and use it in GitHub Desktop.
Save zeen/739591 to your computer and use it in GitHub Desktop.
Limits subscription requests to admins
-- mod_limit_subscription
-- Limits subscription requests to admins
local st = require "util.stanza";
local is_admin = usermanager.is_admin;
function subscription_handler(event)
local origin, stanza = event.origin, event.stanza;
if stanza.attr.type == "subscribe" and not is_admin(origin.full_jid, module.host) then
origin.send(st.error_reply(stanza, "cancel", "not-authorized"));
return true;
end
end
module:hook("pre-presence/bare", subscription_handler, 100);
module:hook("pre-presence/full", subscription_handler, 100);
module:hook("pre-presence/host", subscription_handler, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment