plugins/muc/muc.lib.lua
changeset 5611 e043d4d65423
parent 5601 f55ab5fa939f
child 5612 5404832d6f7a
equal deleted inserted replaced
5610:f73d5fb4ea13 5611:e043d4d65423
    70 
    70 
    71 local function is_kickable_error(stanza)
    71 local function is_kickable_error(stanza)
    72 	local cond = get_error_condition(stanza);
    72 	local cond = get_error_condition(stanza);
    73 	return kickable_error_conditions[cond] and cond;
    73 	return kickable_error_conditions[cond] and cond;
    74 end
    74 end
    75 local function getUsingPath(stanza, path, getText)
       
    76 	local tag = stanza;
       
    77 	for _, name in ipairs(path) do
       
    78 		if type(tag) ~= 'table' then return; end
       
    79 		tag = tag:child_with_name(name);
       
    80 	end
       
    81 	if tag and getText then tag = table.concat(tag); end
       
    82 	return tag;
       
    83 end
       
    84 local function getTag(stanza, path) return getUsingPath(stanza, path); end
       
    85 local function getText(stanza, path) return getUsingPath(stanza, path, true); end
       
    86 -----------
    75 -----------
    87 
    76 
    88 local room_mt = {};
    77 local room_mt = {};
    89 room_mt.__index = room_mt;
    78 room_mt.__index = room_mt;
    90 
    79 
   865 		elseif occupant.role == "visitor" then
   854 		elseif occupant.role == "visitor" then
   866 			origin.send(st.error_reply(stanza, "auth", "forbidden"));
   855 			origin.send(st.error_reply(stanza, "auth", "forbidden"));
   867 		else
   856 		else
   868 			local from = stanza.attr.from;
   857 			local from = stanza.attr.from;
   869 			stanza.attr.from = current_nick;
   858 			stanza.attr.from = current_nick;
   870 			local subject = getText(stanza, {"subject"});
   859 			local subject = stanza:get_child_text("subject");
   871 			if subject then
   860 			if subject then
   872 				if occupant.role == "moderator" or
   861 				if occupant.role == "moderator" or
   873 					( self._data.changesubject and occupant.role == "participant" ) then -- and participant
   862 					( self._data.changesubject and occupant.role == "participant" ) then -- and participant
   874 					self:set_subject(current_nick, subject); -- TODO use broadcast_message_stanza
   863 					self:set_subject(current_nick, subject); -- TODO use broadcast_message_stanza
   875 				else
   864 				else