Mercurial > prosody-modules
annotate mod_block_subscribes/mod_block_subscribes.lua @ 4581:3e2e708fd18b
mod_adhoc_dataforms_demo: Add compat with 0.11 (vs trunk api change)
The name of the "access for anyone" permission level changed from "user"
in 0.11 to "any" in 0.12/trunk to make it clearer that it's basically
unrestricted. This is unfortunately not backwards-compatible.
Thanks to Sam for stumbling upon this during a demo.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 01 Jun 2021 19:23:32 +0200 |
parents | f88381a39c56 |
children |
rev | line source |
---|---|
926
f88381a39c56
mod_block_subscribes: Block inbound and outbound subscription requests (useful to prevent implicit roster modification)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local allowed_presence_types = { probe = true, unavailable = true }; |
f88381a39c56
mod_block_subscribes: Block inbound and outbound subscription requests (useful to prevent implicit roster modification)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 |
f88381a39c56
mod_block_subscribes: Block inbound and outbound subscription requests (useful to prevent implicit roster modification)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 function filter_presence(event) |
f88381a39c56
mod_block_subscribes: Block inbound and outbound subscription requests (useful to prevent implicit roster modification)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 local stanza = event.stanza; |
f88381a39c56
mod_block_subscribes: Block inbound and outbound subscription requests (useful to prevent implicit roster modification)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 local presence_type = stanza.attr.type; |
f88381a39c56
mod_block_subscribes: Block inbound and outbound subscription requests (useful to prevent implicit roster modification)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 if presence_type == nil or allowed_presence_types[presence_type] then |
f88381a39c56
mod_block_subscribes: Block inbound and outbound subscription requests (useful to prevent implicit roster modification)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 return; |
f88381a39c56
mod_block_subscribes: Block inbound and outbound subscription requests (useful to prevent implicit roster modification)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 end |
f88381a39c56
mod_block_subscribes: Block inbound and outbound subscription requests (useful to prevent implicit roster modification)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 return true; -- Drop |
f88381a39c56
mod_block_subscribes: Block inbound and outbound subscription requests (useful to prevent implicit roster modification)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 end |
f88381a39c56
mod_block_subscribes: Block inbound and outbound subscription requests (useful to prevent implicit roster modification)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 |
f88381a39c56
mod_block_subscribes: Block inbound and outbound subscription requests (useful to prevent implicit roster modification)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 module:hook("pre-presence/bare", filter_presence, 200); -- Client sending |
f88381a39c56
mod_block_subscribes: Block inbound and outbound subscription requests (useful to prevent implicit roster modification)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 module:hook("presence/bare", filter_presence, 200); -- Client receiving |