comparison mod_unsubscriber/mod_unsubscriber.lua @ 5168:e00dc913d965

mod_unsubscriber: Revoke roster subscriptions of unreachable hosts Wrote a version of this long ago, but it was lost to time. Here it is again, from scratch!
author Kim Alvefur <zash@zash.se>
date Sun, 19 Feb 2023 17:39:04 +0100
parents
children
comparison
equal deleted inserted replaced
5167:272a8e54f0c8 5168:e00dc913d965
1 assert(module:get_host_type() == "component", "This module should be loaded as a Component");
2
3 local st = require "util.stanza";
4
5 module:hook("presence/bare", function(event)
6 local origin, stanza = event.origin, event.stanza;
7 if stanza.attr.type == "probe" then
8 -- they are subscribed and want our current presence
9 -- tell them we denied their subscription
10 local reply = st.reply(stanza)
11 reply.attr.type = "unsubcribed";
12 origin.send(reply);
13 return true;
14 elseif stanza.attr.type == nil then
15 -- they think we are subscribed and sent their current presence
16 -- tell them we unsubscribe
17 local reply = st.reply(stanza)
18 reply.attr.type = "unsubcribe";
19 origin.send(reply);
20 return true;
21 end
22 -- fall trough to default error
23 end);