Don't send too big timeout to bandwidth

Stephen Paul Weber created

Change summary

lib/customer_fwd.rb       | 2 +-
test/test_customer_fwd.rb | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)

Detailed changes

lib/customer_fwd.rb 🔗

@@ -22,7 +22,7 @@ class CustomerFwd
 		end
 
 		def initialize(s)
-			@timeout = s.nil? || s.to_i.negative? ? 300 : s.to_i
+			@timeout = s.nil? || s.to_i.negative? || s.to_i > 300 ? 300 : s.to_i
 		end
 
 		def zero?

test/test_customer_fwd.rb 🔗

@@ -12,6 +12,11 @@ class Rantly
 end
 
 class CustomerFwdTest < Minitest::Test
+	def test_too_big_timeout
+		fwd = CustomerFwd.for(uri: "xmpp:test@example.com", timeout: 500)
+		assert_equal 300, fwd.timeout.to_i
+	end
+
 	property(:for_xmpp) { jid }
 	def for_xmpp(jid)
 		sip = "sip:#{ERB::Util.url_encode(jid.to_s)}@sip.cheogram.com"