Comparison

mod_block_s2s_subscriptions/mod_block_s2s_subscriptions.lua @ 775:70ff25db37fa

mod_block_s2s_subscriptions: New module to block incoming presence subscriptions from non-contacts on selected remote hosts
author Matthew Wild <mwild1@gmail.com>
date Sun, 05 Aug 2012 02:27:58 +0100
comparison
equal deleted inserted replaced
774:52caf54fc270 775:70ff25db37fa
1
2 local jid_split = require "util.jid".split;
3 local jid_bare = require "util.jid".bare;
4 local load_roster = require "core.rostermanager".load_roster;
5
6 local blocked_servers = module:get_option_set("block_s2s_subscriptions")._items;
7
8 function filter_presence(event)
9 if blocked_servers[event.origin.from_host] and event.stanza.attr.type == "subscribe" then
10 local stanza = event.stanza;
11 local to_user, to_host = jid_split(stanza.attr.to);
12 local roster = load_roster(to_user, to_host);
13 if roster and roster[jid_bare(stanza.attr.from)] then
14 return; -- In roster, pass through
15 end
16 return true; -- Drop
17 end
18 end
19
20 module:hook("presence/bare", filter_presence, 200); -- Client receiving