MUC: Split long lines [luacheck strict]
authorKim Alvefur <zash@zash.se>
Fri, 03 Aug 2018 17:48:41 +0200
changeset 9084 ce57c69a20e2
parent 9083 1b21f8ffaec8
child 9085 297a06074175
MUC: Split long lines [luacheck strict]
plugins/muc/history.lib.lua
plugins/muc/mod_muc.lua
plugins/muc/muc.lib.lua
plugins/muc/request.lib.lua
plugins/muc/whois.lib.lua
--- a/plugins/muc/history.lib.lua	Fri Aug 03 17:15:42 2018 +0200
+++ b/plugins/muc/history.lib.lua	Fri Aug 03 17:48:41 2018 +0200
@@ -177,8 +177,12 @@
 	stanza.attr.to = "";
 	local ts = gettime();
 	local stamp = datetime.datetime(ts);
-	stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = module.host, stamp = stamp}):up(); -- XEP-0203
-	stanza:tag("x", {xmlns = "jabber:x:delay", from = module.host, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated)
+	stanza:tag("delay", { -- XEP-0203
+		xmlns = "urn:xmpp:delay", from = module.host, stamp = stamp
+	}):up();
+	stanza:tag("x", { -- XEP-0091 (deprecated)
+		xmlns = "jabber:x:delay", from = module.host, stamp = datetime.legacy()
+	}):up();
 	local entry = { stanza = stanza, timestamp = ts };
 	table.insert(history, entry);
 	while #history > get_historylength(room) do table.remove(history, 1) end
--- a/plugins/muc/mod_muc.lua	Fri Aug 03 17:15:42 2018 +0200
+++ b/plugins/muc/mod_muc.lua	Fri Aug 03 17:48:41 2018 +0200
@@ -320,9 +320,11 @@
 	room:set_public(module:get_option_boolean("muc_room_default_public", false));
 	room:set_persistent(module:get_option_boolean("muc_room_default_persistent", room:get_persistent()));
 	room:set_members_only(module:get_option_boolean("muc_room_default_members_only", room:get_members_only()));
-	room:set_allow_member_invites(module:get_option_boolean("muc_room_default_allow_member_invites", room:get_allow_member_invites()));
+	room:set_allow_member_invites(module:get_option_boolean("muc_room_default_allow_member_invites",
+		room:get_allow_member_invites()));
 	room:set_moderated(module:get_option_boolean("muc_room_default_moderated", room:get_moderated()));
-	room:set_whois(module:get_option_boolean("muc_room_default_public_jids", room:get_whois() == "anyone") and "anyone" or "moderators");
+	room:set_whois(module:get_option_boolean("muc_room_default_public_jids",
+		room:get_whois() == "anyone") and "anyone" or "moderators");
 	room:set_changesubject(module:get_option_boolean("muc_room_default_change_subject", room:get_changesubject()));
 	room:set_historylength(module:get_option_number("muc_room_default_history_length", room:get_historylength()));
 	room:set_language(event.stanza.attr["xml:lang"] or module:get_option_string("muc_room_default_language"));
@@ -416,7 +418,8 @@
 		local room = get_room_from_jid(room_jid);
 
 		if room and room._data.destroyed then
-			if room._data.locked < os.time() or (is_admin(stanza.attr.from) and stanza.name == "presence" and stanza.attr.type == nil) then
+			if room._data.locked < os.time()
+			or (is_admin(stanza.attr.from) and stanza.name == "presence" and stanza.attr.type == nil) then
 				-- Allow the room to be recreated by admin or after time has passed
 				delete_room(room);
 				room = nil;
@@ -487,7 +490,8 @@
 		end
 		return { status = "completed", info = "The following rooms were destroyed:\n"..t_concat(fields.rooms, "\n") };
 	end);
-	local destroy_rooms_desc = adhoc_new("Destroy Rooms", "http://prosody.im/protocol/muc#destroy", destroy_rooms_handler, "admin");
+	local destroy_rooms_desc = adhoc_new("Destroy Rooms",
+		"http://prosody.im/protocol/muc#destroy", destroy_rooms_handler, "admin");
 
 	module:provides("adhoc", destroy_rooms_desc);
 end
--- 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
--- a/plugins/muc/request.lib.lua	Fri Aug 03 17:15:42 2018 +0200
+++ b/plugins/muc/request.lib.lua	Fri Aug 03 17:48:41 2018 +0200
@@ -81,7 +81,8 @@
 			["muc#roomnick"] = nick;
 		};
 
-		local message = st.message({ type = "normal"; from = event.room.jid }):add_child(voice_request_form:form(formdata)):up();
+		local message = st.message({ type = "normal"; from = event.room.jid })
+			:add_direct_child(voice_request_form:form(formdata));
 
 		event.room:broadcast(message, function (_, occupant)
 			return occupant.role == "moderator";
@@ -105,12 +106,14 @@
 	end
 
 	if not affected_occupant then
-		module:log("debug", "%s tried to grant voice to unknown occupant %s", jid_resource(occupant.nick), event.fields["muc#jid"]);
+		module:log("debug", "%s tried to grant voice to unknown occupant %s",
+			jid_resource(occupant.nick), event.fields["muc#jid"]);
 		return;
 	end
 
 	if affected_occupant.role ~= "visitor" then
-		module:log("debug", "%s tried to grant voice to %s but they already have it", jid_resource(occupant.nick), jid_resource(occupant.jid));
+		module:log("debug", "%s tried to grant voice to %s but they already have it",
+			jid_resource(occupant.nick), jid_resource(occupant.jid));
 		return;
 	end
 
--- a/plugins/muc/whois.lib.lua	Fri Aug 03 17:15:42 2018 +0200
+++ b/plugins/muc/whois.lib.lua	Fri Aug 03 17:48:41 2018 +0200
@@ -24,7 +24,8 @@
 end
 
 module:hook("muc-disco#info", function(event)
-	event.reply:tag("feature", {var = get_whois(event.room) ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up();
+	local whois = get_whois(event.room) ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous";
+	event.reply:tag("feature", { var = whois }):up();
 end);
 
 module:hook("muc-config-form", function(event)