mod_admin_shell: Remove now redundant promise awaiting in xmpp:ping()
authorKim Alvefur <zash@zash.se>
Sat, 27 Nov 2021 14:15:55 +0100
changeset 11957 848a522fd731
parent 11956 b78a341e72e7
child 11958 b963ac00c967
mod_admin_shell: Remove now redundant promise awaiting in xmpp:ping()
plugins/mod_admin_shell.lua
--- a/plugins/mod_admin_shell.lua	Sat Nov 27 12:53:56 2021 +0100
+++ b/plugins/mod_admin_shell.lua	Sat Nov 27 14:15:55 2021 +0100
@@ -1350,12 +1350,9 @@
 	local iq = st.iq{ from=localhost, to=remotehost, type="get", id=new_id()}
 			:tag("ping", {xmlns="urn:xmpp:ping"});
 	local time_start = time.now();
-	local ret, err = async.wait_for(module:context(localhost):send_iq(iq, nil, timeout));
-	if ret then
-		return true, ("pong from %s in %gs"):format(ret.stanza.attr.from, time.now() - time_start);
-	else
-		return false, tostring(err);
-	end
+	return module:context(localhost):send_iq(iq, nil, timeout):next(function (pong)
+		return ("pong from %s in %gs"):format(pong.stanza.attr.from, time.now() - time_start);
+	end);
 end
 
 def_env.dns = {};