Mercurial > prosody-modules
annotate mod_unsubscriber/mod_unsubscriber.lua @ 6513:5fb466693e85
mod_storage_xmlarchive: Ensure list index files are removed
using os.remove() on the list files leaves the new index files behind
since util.datamanager does not know they are removed.
Thanks Link Mauve
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 07 Apr 2026 21:10:54 +0200 |
| parents | 9c9889ad4302 |
| 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 |
|
6398
9c9889ad4302
mod_unsubscriber: Add MUC support
Kim Alvefur <zash@zash.se>
parents:
5168
diff
changeset
|
15 if stanza:get_child("x", "http://jabber.org/protocol/muc") then |
|
9c9889ad4302
mod_unsubscriber: Add MUC support
Kim Alvefur <zash@zash.se>
parents:
5168
diff
changeset
|
16 -- attempting to join a MUC |
|
9c9889ad4302
mod_unsubscriber: Add MUC support
Kim Alvefur <zash@zash.se>
parents:
5168
diff
changeset
|
17 -- tell them it's gone |
|
9c9889ad4302
mod_unsubscriber: Add MUC support
Kim Alvefur <zash@zash.se>
parents:
5168
diff
changeset
|
18 local reply = st.error_reply(stanza, "cancel", "gone"); |
|
9c9889ad4302
mod_unsubscriber: Add MUC support
Kim Alvefur <zash@zash.se>
parents:
5168
diff
changeset
|
19 origin.send(reply); |
|
9c9889ad4302
mod_unsubscriber: Add MUC support
Kim Alvefur <zash@zash.se>
parents:
5168
diff
changeset
|
20 return true; |
|
9c9889ad4302
mod_unsubscriber: Add MUC support
Kim Alvefur <zash@zash.se>
parents:
5168
diff
changeset
|
21 end |
|
5168
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 -- 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
|
23 -- tell them we unsubscribe |
|
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 local reply = st.reply(stanza) |
|
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 reply.attr.type = "unsubcribe"; |
|
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 origin.send(reply); |
|
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 return true; |
|
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 end |
|
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 -- fall trough to default error |
|
e00dc913d965
mod_unsubscriber: Revoke roster subscriptions of unreachable hosts
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 end); |
