Mercurial > prosody-hg
comparison plugins/muc/muc.lib.lua @ 8913:560419b759c8
MUC: Remove support for GC 1.0 during room creation
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 09 Mar 2018 19:02:10 +0100 |
| parents | 43806beda970 |
| children | e9acb928c637 |
comparison
equal
deleted
inserted
replaced
| 8912:43806beda970 | 8913:560419b759c8 |
|---|---|
| 376 module:fire_event("muc-occupant-left", {room = self; nick = occupant.nick; occupant = occupant;}); | 376 module:fire_event("muc-occupant-left", {room = self; nick = occupant.nick; occupant = occupant;}); |
| 377 end | 377 end |
| 378 return true; | 378 return true; |
| 379 end | 379 end |
| 380 | 380 |
| 381 if not module:get_option_boolean("muc_compat_create", true) then | |
| 382 module:hook("muc-room-pre-create", function(event) | |
| 383 local origin, stanza = event.origin, event.stanza; | |
| 384 if not stanza:get_child("x", "http://jabber.org/protocol/muc") then | |
| 385 origin.send(st.error_reply(stanza, "cancel", "item-not-found")); | |
| 386 return true; | |
| 387 end | |
| 388 end, -1); | |
| 389 end | |
| 390 | |
| 391 -- Give the room creator owner affiliation | 381 -- Give the room creator owner affiliation |
| 392 module:hook("muc-room-pre-create", function(event) | 382 module:hook("muc-room-pre-create", function(event) |
| 393 event.room:set_affiliation(true, jid_bare(event.stanza.attr.from), "owner"); | 383 event.room:set_affiliation(true, jid_bare(event.stanza.attr.from), "owner"); |
| 394 end, -1); | 384 end, -1); |
| 395 | 385 |
| 404 return true; | 394 return true; |
| 405 end | 395 end |
| 406 end, -10); | 396 end, -10); |
| 407 | 397 |
| 408 function room_mt:handle_first_presence(origin, stanza) | 398 function room_mt:handle_first_presence(origin, stanza) |
| 399 if not stanza:get_child("x", "http://jabber.org/protocol/muc") then | |
| 400 module:log("debug", "Room creation without <x>, possibly desynced"); | |
| 401 | |
| 402 origin.send(st.error_reply(stanza, "cancel", "item-not-found")); | |
| 403 return true; | |
| 404 end | |
| 405 | |
| 409 local real_jid = stanza.attr.from; | 406 local real_jid = stanza.attr.from; |
| 410 local dest_jid = stanza.attr.to; | 407 local dest_jid = stanza.attr.to; |
| 411 local bare_jid = jid_bare(real_jid); | 408 local bare_jid = jid_bare(real_jid); |
| 412 if module:fire_event("muc-room-pre-create", { | 409 if module:fire_event("muc-room-pre-create", { |
| 413 room = self; | 410 room = self; |
| 414 origin = origin; | 411 origin = origin; |
| 415 stanza = stanza; | 412 stanza = stanza; |
| 416 }) then return true; end | 413 }) then return true; end |
| 417 local is_first_dest_session = true; | 414 local is_first_dest_session = true; |
| 418 local dest_occupant = self:new_occupant(bare_jid, dest_jid); | 415 local dest_occupant = self:new_occupant(bare_jid, dest_jid); |
| 419 | |
| 420 -- TODO Handle this case sensibly | |
| 421 if not stanza:get_child("x", "http://jabber.org/protocol/muc") then | |
| 422 module:log("debug", "Room creation without <x>, possibly desynced"); | |
| 423 end | |
| 424 | 416 |
| 425 local orig_nick = dest_occupant.nick; | 417 local orig_nick = dest_occupant.nick; |
| 426 if module:fire_event("muc-occupant-pre-join", { | 418 if module:fire_event("muc-occupant-pre-join", { |
| 427 room = self; | 419 room = self; |
| 428 origin = origin; | 420 origin = origin; |
