Software /
code /
prosody-modules
Comparison
mod_muc_rai/mod_muc_rai.lua @ 4277:10dc4527574f
mod_muc_rai: Subscribe/unsubscribe users when leaving/joining
author | Seve Ferrer <seve@delape.net> |
---|---|
date | Tue, 01 Dec 2020 16:45:20 +0100 |
parent | 4074:4b84beb48ba0 |
child | 4281:3c80e46e26f2 |
comparison
equal
deleted
inserted
replaced
4276:ec33b3b1136c | 4277:10dc4527574f |
---|---|
184 end | 184 end |
185 end | 185 end |
186 return rooms_with_activity; | 186 return rooms_with_activity; |
187 end | 187 end |
188 | 188 |
189 module:hook("muc-occupant-joined", function(event) | |
190 local room_jid, user_jid = event.room.jid, event.stanza.attr.from; | |
191 local ok, err = unsubscribe_room(user_jid, room_jid); | |
192 if ok then | |
193 module:log("debug", "Unsubscribed " .. user_jid .. " from " .. room_jid .. " Reason: muc-occupant-joined") | |
194 end | |
195 end); | |
196 | |
197 module:hook("muc-occupant-left", function(event) | |
198 local room_jid, user_jid = event.room.jid, event.stanza.attr.from; | |
199 local ok, err = subscribe_room(user_jid, room_jid); | |
200 if ok then | |
201 module:log("debug", "Subscribed " .. user_jid .. " to " .. room_jid .. " Reason: muc-occupant-left") | |
202 end | |
203 end); | |
204 | |
189 module:hook("presence/host", function (event) | 205 module:hook("presence/host", function (event) |
190 local origin, stanza = event.origin, event.stanza; | 206 local origin, stanza = event.origin, event.stanza; |
191 local user_jid = stanza.attr.from; | 207 local user_jid = stanza.attr.from; |
192 | 208 |
193 if stanza.attr.type == "unavailable" then -- User going offline | 209 if stanza.attr.type == "unavailable" then -- User going offline |