changeset 13875:9a2075e3e383 13.0

MUC: Factor out identification of join stanza Makes it easier to extend this condition without the line growing too long.
author Kim Alvefur <zash@zash.se>
date Mon, 19 May 2025 18:11:27 +0200
parents 9eee04a95a25
children 3609d8fcad00
files plugins/muc/mod_muc.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/muc/mod_muc.lua	Mon May 05 16:32:45 2025 +0200
+++ b/plugins/muc/mod_muc.lua	Mon May 19 18:11:27 2025 +0200
@@ -441,6 +441,12 @@
 	end
 end);
 
+local function is_join_presence(stanza)
+	return stanza.name == "presence"
+		and stanza.attr.type == nil
+		and stanza:get_child("x", "http://jabber.org/protocol/muc");
+end
+
 for event_name, method in pairs {
 	-- Normal room interactions
 	["iq-get/bare/http://jabber.org/protocol/disco#info:query"] = "handle_disco_info_get_query" ;
@@ -496,7 +502,7 @@
 				origin.send(st.error_reply(stanza, "modify", "jid-malformed", nil, module.host));
 				return true;
 			end
-			if stanza.attr.type == nil and stanza.name == "presence" and stanza:get_child("x", "http://jabber.org/protocol/muc") then
+			if is_join_presence(stanza) then
 				room = muclib.new_room(room_jid);
 				return room:handle_first_presence(origin, stanza);
 			elseif stanza.attr.type ~= "error" then