# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1588974857 -7200
# Node ID 86ea811ee25b663210ceeac543fad8eae3eb9d5e
# Parent  0d365c0ee9fef3ed5d78a8deeaf94ff7262b45d9
mod_s2s: Improve signaling of stream open events

Makes it clearer, cleaner and easier to extend.

diff -r 0d365c0ee9fe -r 86ea811ee25b plugins/mod_s2s/mod_s2s.lua
--- a/plugins/mod_s2s/mod_s2s.lua	Thu May 07 23:02:47 2020 +0200
+++ b/plugins/mod_s2s/mod_s2s.lua	Fri May 08 23:54:17 2020 +0200
@@ -322,7 +322,7 @@
 
 function stream_callbacks.streamopened(session, attr)
 	-- run _streamopened in async context
-	session.thread:run({ attr = attr });
+	session.thread:run({ stream = "opened", attr = attr });
 end
 
 function stream_callbacks._streamopened(session, attr)
@@ -564,10 +564,10 @@
 	local stream = new_xmpp_stream(session, stream_callbacks);
 
 	session.thread = runner(function (stanza)
-		if stanza.name == nil then
+		if st.is_stanza(stanza) then
+			core_process_stanza(session, stanza);
+		elseif stanza.stream == "opened" then
 			stream_callbacks._streamopened(session, stanza.attr);
-		else
-			core_process_stanza(session, stanza);
 		end
 	end, runner_callbacks, session);