Diff

plugins/muc/muc.lib.lua @ 9081:ce57c69a20e2

MUC: Split long lines [luacheck strict]
author Kim Alvefur <zash@zash.se>
date Fri, 03 Aug 2018 17:48:41 +0200
parent 9057:df18f8398548
child 9145:51c5dd7a8ab9
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua	Fri Aug 03 17:15:42 2018 +0200
+++ b/plugins/muc/muc.lib.lua	Fri Aug 03 17:48:41 2018 +0200
@@ -492,7 +492,8 @@
 
 	if orig_occupant == nil and not muc_x and stanza.attr.type == nil then
 		module:log("debug", "Attempted join without <x>, possibly desynced");
-		origin.send(st.error_reply(stanza, "cancel", "item-not-found", "You must join the room before sending presence updates"));
+		origin.send(st.error_reply(stanza, "cancel", "item-not-found",
+			"You must join the room before sending presence updates"));
 		return true;
 	end
 
@@ -591,7 +592,8 @@
 				orig_occupant:remove_session(real_jid);
 				log("debug", "generating nick change for %s", real_jid);
 				local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user";});
-				-- self:build_item_list(orig_occupant, x, false, dest_nick); -- COMPAT: clients get confused if they see other items besides their own
+				-- COMPAT: clients get confused if they see other items besides their own
+				-- self:build_item_list(orig_occupant, x, false, dest_nick);
 				add_item(x, self:get_affiliation(bare_jid), orig_occupant.role, real_jid, dest_nick);
 				x:tag("status", {code = "303";}):up();
 				x:tag("status", {code = "110";}):up();
@@ -635,7 +637,8 @@
 		end
 		self:publicise_occupant_status(dest_occupant, {base=dest_x,self=self_x});
 
-		if orig_occupant ~= nil and orig_occupant ~= dest_occupant and not is_last_orig_session then -- If user is swapping and wasn't last original session
+		if orig_occupant ~= nil and orig_occupant ~= dest_occupant and not is_last_orig_session then
+			-- If user is swapping and wasn't last original session
 			log("debug", "session %s split nicks; showing %s rejoining", real_jid, orig_occupant.nick);
 			-- Show the original nick joining again
 			local pr = st.clone(orig_occupant:get_presence());
@@ -892,7 +895,8 @@
 			return true;
 		end
 	end
-	if not item.attr.jid and item.attr.nick then -- COMPAT Workaround for Miranda sending 'nick' instead of 'jid' when changing affiliation
+	if not item.attr.jid and item.attr.nick then
+		-- COMPAT Workaround for Miranda sending 'nick' instead of 'jid' when changing affiliation
 		local occupant = self:get_occupant_by_nick(self.jid.."/"..item.attr.nick);
 		if occupant then item.attr.jid = occupant.jid; end
 	elseif not item.attr.nick and item.attr.jid then
@@ -1131,9 +1135,8 @@
 	if not stanza:get_child("body") then
 		local decline = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("decline");
 		local reason = decline:get_child_text("reason") or "";
-		stanza:tag("body")
-			:text(decline.attr.from.." declined your invite to the room "..room.jid..(reason ~= "" and (" ("..reason..")") or ""))
-		:up();
+		stanza:body(decline.attr.from.." declined your invite to the room "
+			..room.jid..(reason ~= "" and (" ("..reason..")") or ""));
 	end
 end);
 
@@ -1173,8 +1176,9 @@
 
 function room_mt:get_affiliation(jid)
 	local node, host, resource = jid_split(jid);
+	-- Affiliations are granted, revoked, and maintained based on the user's bare JID.
 	local bare = node and node.."@"..host or host;
-	local result = self._affiliations[bare]; -- Affiliations are granted, revoked, and maintained based on the user's bare JID.
+	local result = self._affiliations[bare];
 	if not result and self._affiliations[host] == "outcast" then result = "outcast"; end -- host banned
 	return result;
 end