Mercurial > prosody-modules
comparison mod_block_strangers/mod_block_strangers.lua @ 1324:853a382c9bd6
mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 28 Feb 2014 15:36:06 +0100 |
| parents | 52caf54fc270 |
| children | b21236b6b8d8 |
comparison
equal
deleted
inserted
replaced
| 1323:c84ff82658cb | 1324:853a382c9bd6 |
|---|---|
| 1 | 1 |
| 2 local jid_split = require "util.jid".split; | 2 local jid_split = require "util.jid".split; |
| 3 local jid_bare = require "util.jid".bare; | 3 local jid_bare = require "util.jid".bare; |
| 4 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed; | 4 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed; |
| 5 local error_reply = require "util.stanza".error_reply; | |
| 5 | 6 |
| 6 function check_subscribed(event) | 7 function check_subscribed(event) |
| 7 local stanza = event.stanza; | 8 local stanza = event.stanza; |
| 8 local to_user, to_host, to_resource = jid_split(stanza.attr.to); | 9 local to_user, to_host, to_resource = jid_split(stanza.attr.to); |
| 9 local from_jid = jid_bare(stanza.attr.from); | 10 local from_jid = jid_bare(stanza.attr.from); |
| 10 if to_user and not is_contact_subscribed(to_user, to_host, from_jid) then | 11 if to_user and not is_contact_subscribed(to_user, to_host, from_jid) then |
| 11 if to_resource and stanza.attr.type == "groupchat" then | 12 if to_resource and stanza.attr.type == "groupchat" then |
| 12 return nil; -- Pass through | 13 return nil; -- Pass through |
| 13 end | 14 end |
| 14 return true; -- Drop stanza | 15 return error_reply("auth", "forbidden", "Subscription required"); -- Bounce with error |
| 15 end | 16 end |
| 16 end | 17 end |
| 17 | 18 |
| 18 module:hook("message/bare", check_subscribed, 200); | 19 module:hook("message/bare", check_subscribed, 200); |
| 19 module:hook("message/full", check_subscribed, 200); | 20 module:hook("message/full", check_subscribed, 200); |
