# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1666268556 -7200
# Node ID 871d2c95b40351d58a53a21279b59d2873edb63a
# Parent  71bd009a97898b04abcd91dc657c8fd76b20bee0
mod_s2s: Advertise stream features on bidi connections

diff -r 71bd009a9789 -r 871d2c95b403 plugins/mod_s2s.lua
--- a/plugins/mod_s2s.lua	Thu Oct 20 14:12:56 2022 +0200
+++ b/plugins/mod_s2s.lua	Thu Oct 20 14:22:36 2022 +0200
@@ -247,6 +247,12 @@
 	end
 	module:hook("route/remote", route_to_existing_session, -1);
 	module:hook("route/remote", route_to_new_session, -10);
+	module:hook("s2sout-stream-features", function (event)
+		if stanza_size_limit then
+			event.features:tag("limits", { xmlns = "urn:xmpp:stream-limits:0" })
+				:text_tag("max-size", string.format("%d", stanza_size_limit)):up();
+		end
+	end);
 	module:hook("s2s-authenticated", make_authenticated, -1);
 	module:hook("s2s-read-timeout", keepalive, -1);
 	module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza) -- luacheck: ignore 212/stanza