Software / code / prosody-modules
Comparison
mod_muc_rai/mod_muc_rai.lua @ 4335:e03dadd4f2d1
mod_muc_rai: Get user JID from event.occupant
`event.stanza` isn't always available.
| author | JC Brand <jc@opkode.com> |
|---|---|
| date | Wed, 13 Jan 2021 16:23:44 +0100 |
| parent | 4297:4a5c4a352b78 |
| child | 4510:6690586826e8 |
comparison
equal
deleted
inserted
replaced
| 4334:d90ce7dc3f88 | 4335:e03dadd4f2d1 |
|---|---|
| 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 --- FIXME: | |
| 190 -- The subscribe/unsubscribe code below doesn't work in the case where | |
| 191 -- the user joins from multiple resources with the same nick. | |
| 192 -- | |
| 193 -- For example, resource A joining, followed by resource B joining, followed | |
| 194 -- by A leaving and B leaving will ultimately trigger muc-occupant-joined for | |
| 195 -- resource A and muc-occupant-left for resource B. | |
| 196 | |
| 189 module:hook("muc-occupant-joined", function(event) | 197 module:hook("muc-occupant-joined", function(event) |
| 190 local room_jid, user_jid = event.room.jid, event.stanza.attr.from; | 198 local room_jid, user_jid = event.room.jid, event.stanza.attr.from; |
| 191 local ok, _ = unsubscribe_room(user_jid, room_jid); | 199 local ok, _ = unsubscribe_room(user_jid, room_jid); |
| 192 if ok then | 200 if ok then |
| 193 module:log("debug", "Unsubscribed %s to %s Reason: muc-occupant-joined", user_jid, room_jid) | 201 module:log("debug", "Unsubscribed %s to %s Reason: muc-occupant-joined", user_jid, room_jid) |
| 194 end | 202 end |
| 195 end); | 203 end); |
| 196 | 204 |
| 197 module:hook("muc-occupant-left", function(event) | 205 module:hook("muc-occupant-left", function(event) |
| 198 local room_jid, user_jid = event.room.jid, event.stanza.attr.from; | 206 local room_jid, user_jid = event.room.jid, event.occupant.jid; |
| 199 local ok, _ = subscribe_room(user_jid, room_jid); | 207 local ok, _ = subscribe_room(user_jid, room_jid); |
| 200 if ok then | 208 if ok then |
| 201 module:log("debug", "Subscribed %s to %s Reason: muc-occupant-left", user_jid, room_jid) | 209 module:log("debug", "Subscribed %s to %s Reason: muc-occupant-left", user_jid, room_jid) |
| 202 end | 210 end |
| 203 end); | 211 end); |