comparison plugins/muc/mod_muc.lua @ 13877:4e109e917f89

Merge 13.0->trunk
author Kim Alvefur <zash@zash.se>
date Mon, 19 May 2025 18:41:55 +0200
parents 3609d8fcad00
children c6010e1322aa
comparison
equal deleted inserted replaced
13874:bfa8ac5881a0 13877:4e109e917f89
102 room_mt.get_occupant_id = occupant_id.get_occupant_id; 102 room_mt.get_occupant_id = occupant_id.get_occupant_id;
103 103
104 local jid_split = require "prosody.util.jid".split; 104 local jid_split = require "prosody.util.jid".split;
105 local jid_prep = require "prosody.util.jid".prep; 105 local jid_prep = require "prosody.util.jid".prep;
106 local jid_bare = require "prosody.util.jid".bare; 106 local jid_bare = require "prosody.util.jid".bare;
107 local jid_resource = require "prosody.util.jid".resource;
107 local st = require "prosody.util.stanza"; 108 local st = require "prosody.util.stanza";
108 local cache = require "prosody.util.cache"; 109 local cache = require "prosody.util.cache";
109 110
110 module:require "muc/config_form_sections"; 111 module:require "muc/config_form_sections";
111 112
438 if restrict_room_creation ~= false and not module:may(":create-room", event) then 439 if restrict_room_creation ~= false and not module:may(":create-room", event) then
439 origin.send(st.error_reply(stanza, "cancel", "not-allowed", "Room creation is restricted", module.host)); 440 origin.send(st.error_reply(stanza, "cancel", "not-allowed", "Room creation is restricted", module.host));
440 return true; 441 return true;
441 end 442 end
442 end); 443 end);
444
445 local function is_join_presence(stanza)
446 return stanza.name == "presence"
447 and stanza.attr.type == nil
448 and jid_resource(stanza.attr.to) ~= nil
449 and stanza:get_child("x", "http://jabber.org/protocol/muc");
450 end
443 451
444 for event_name, method in pairs { 452 for event_name, method in pairs {
445 -- Normal room interactions 453 -- Normal room interactions
446 ["iq-get/bare/http://jabber.org/protocol/disco#info:query"] = "handle_disco_info_get_query" ; 454 ["iq-get/bare/http://jabber.org/protocol/disco#info:query"] = "handle_disco_info_get_query" ;
447 ["iq-get/bare/http://jabber.org/protocol/disco#items:query"] = "handle_disco_items_get_query" ; 455 ["iq-get/bare/http://jabber.org/protocol/disco#items:query"] = "handle_disco_items_get_query" ;
494 -- Watch presence to create rooms 502 -- Watch presence to create rooms
495 if not jid_prep(room_jid, true) then 503 if not jid_prep(room_jid, true) then
496 origin.send(st.error_reply(stanza, "modify", "jid-malformed", nil, module.host)); 504 origin.send(st.error_reply(stanza, "modify", "jid-malformed", nil, module.host));
497 return true; 505 return true;
498 end 506 end
499 if stanza.attr.type == nil and stanza.name == "presence" and stanza:get_child("x", "http://jabber.org/protocol/muc") then 507 if is_join_presence(stanza) then
500 room = muclib.new_room(room_jid); 508 room = muclib.new_room(room_jid);
501 return room:handle_first_presence(origin, stanza); 509 return room:handle_first_presence(origin, stanza);
502 elseif stanza.attr.type ~= "error" then 510 elseif stanza.attr.type ~= "error" then
503 origin.send(st.error_reply(stanza, "cancel", "item-not-found", nil, module.host)); 511 origin.send(st.error_reply(stanza, "cancel", "item-not-found", nil, module.host));
504 return true; 512 return true;