Mercurial > prosody-modules
annotate mod_unsubscriber/mod_unsubscriber.lua @ 5801:73887dcb2129
mod_pubsub_serverinfo: New module that uses pub/sub to make accessible server info
This first implemetnation is laughably simple: it only adds a disco#info
feature. This flags 'opt-in' for inclusion of local domain names in the
data exposed by other domains (per the domain), which will allow servers to
be listed in the XMPP Network Graph at https://xmppnetwork.goodbytes.im
Hopefully, this bare-boned implementation acts as a stepping stone for
future improvements.
author | Guus der Kinderen <guus.der.kinderen@gmail.com> |
---|---|
date | Thu, 28 Dec 2023 11:02:35 +0100 |
parents | e00dc913d965 |
children |
rev | line source |
---|---|
5168
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 assert(module:get_host_type() == "component", "This module should be loaded as a Component"); |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 local st = require "util.stanza"; |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 module:hook("presence/bare", function(event) |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 local origin, stanza = event.origin, event.stanza; |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 if stanza.attr.type == "probe" then |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 -- they are subscribed and want our current presence |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 -- tell them we denied their subscription |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 local reply = st.reply(stanza) |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 reply.attr.type = "unsubcribed"; |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 origin.send(reply); |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 return true; |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 elseif stanza.attr.type == nil then |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 -- they think we are subscribed and sent their current presence |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 -- tell them we unsubscribe |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 local reply = st.reply(stanza) |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 reply.attr.type = "unsubcribe"; |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 origin.send(reply); |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 return true; |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 end |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 -- fall trough to default error |
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 end); |