Diff

plugins/muc/muc.lib.lua @ 6115:b8b68d09c9d8

plugins/muc/muc.lib: Tidy up is_kickable_error: it didn't need to return the condition. Also removes `get_error_condition`; it was a one liner used in one place
author daurnimator <quae@daurnimator.com>
date Wed, 19 Mar 2014 13:59:59 -0400
parent 6114:055efbb6d10c
child 6116:9147e566fde0
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua	Wed Mar 19 13:57:02 2014 -0400
+++ b/plugins/muc/muc.lib.lua	Wed Mar 19 13:59:59 2014 -0400
@@ -27,7 +27,6 @@
 
 local default_history_length, max_history_length = 20, math.huge;
 
-------------
 local presence_filters = {["http://jabber.org/protocol/muc"]=true;["http://jabber.org/protocol/muc#user"]=true};
 local function presence_filter(tag)
 	if presence_filters[tag.attr.xmlns] then
@@ -35,34 +34,29 @@
 	end
 	return tag;
 end
-
 local function get_filtered_presence(stanza)
 	return st.clone(stanza):maptags(presence_filter);
 end
-local kickable_error_conditions = {
-	["gone"] = true;
-	["internal-server-error"] = true;
-	["item-not-found"] = true;
-	["jid-malformed"] = true;
-	["recipient-unavailable"] = true;
-	["redirect"] = true;
-	["remote-server-not-found"] = true;
-	["remote-server-timeout"] = true;
-	["service-unavailable"] = true;
-	["malformed error"] = true;
-};
 
-local function get_error_condition(stanza)
-	local _, condition = stanza:get_error();
-	return condition or "malformed error";
+local is_kickable_error do
+	local kickable_error_conditions = {
+		["gone"] = true;
+		["internal-server-error"] = true;
+		["item-not-found"] = true;
+		["jid-malformed"] = true;
+		["recipient-unavailable"] = true;
+		["redirect"] = true;
+		["remote-server-not-found"] = true;
+		["remote-server-timeout"] = true;
+		["service-unavailable"] = true;
+		["malformed error"] = true;
+	};
+	function is_kickable_error(stanza)
+		local cond = select(2, stanza:get_error()) or "malformed error";
+		return kickable_error_conditions[cond];
+	end
 end
 
-local function is_kickable_error(stanza)
-	local cond = get_error_condition(stanza);
-	return kickable_error_conditions[cond] and cond;
-end
------------
-
 local room_mt = {};
 room_mt.__index = room_mt;