Mercurial > prosody-hg
comparison plugins/muc/mod_muc.lua @ 6179:e488a90195bc
plugins/muc: Massive refactor
We now have occupant objects; you grab them, modify them, save them.
New presence handling code.
Modify all presence sending to go via new functions.
| author | daurnimator <quae@daurnimator.com> |
|---|---|
| date | Thu, 27 Mar 2014 19:16:13 -0400 |
| parents | bf6de8ef66c2 |
| children | 49dd381666f3 |
comparison
equal
deleted
inserted
replaced
| 6143:82b3a2155a55 | 6179:e488a90195bc |
|---|---|
| 226 room._affiliations = oldroom._affiliations; | 226 room._affiliations = oldroom._affiliations; |
| 227 end | 227 end |
| 228 hosts[module:get_host()].muc = { rooms = rooms }; | 228 hosts[module:get_host()].muc = { rooms = rooms }; |
| 229 end | 229 end |
| 230 | 230 |
| 231 function shutdown_room(room, stanza) | |
| 232 for nick, occupant in pairs(room._occupants) do | |
| 233 stanza.attr.from = nick; | |
| 234 for jid in pairs(occupant.sessions) do | |
| 235 stanza.attr.to = jid; | |
| 236 room:_route_stanza(stanza); | |
| 237 room._jid_nick[jid] = nil; | |
| 238 end | |
| 239 room._occupants[nick] = nil; | |
| 240 end | |
| 241 end | |
| 242 function shutdown_component() | 231 function shutdown_component() |
| 243 if not saved then | 232 if not saved then |
| 244 local stanza = st.presence({type = "unavailable"}) | 233 local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"}) |
| 245 :tag("x", {xmlns = "http://jabber.org/protocol/muc#user"}) | |
| 246 :tag("item", { affiliation='none', role='none' }):up() | |
| 247 :tag("status", { code = "332"}):up(); | 234 :tag("status", { code = "332"}):up(); |
| 248 for roomjid, room in pairs(rooms) do | 235 for roomjid, room in pairs(rooms) do |
| 249 shutdown_room(room, stanza); | 236 room:clear(x); |
| 250 end | 237 end |
| 251 shutdown_room(host_room, stanza); | 238 host_room:clear(x); |
| 252 end | 239 end |
| 253 end | 240 end |
| 254 module.unload = shutdown_component; | 241 module.unload = shutdown_component; |
| 255 module:hook_global("server-stopping", shutdown_component); | 242 module:hook_global("server-stopping", shutdown_component); |
| 256 | 243 |
