fallback to sending links if MMS fails

Phillip Davis created

Change summary

sgx-bwmsgsv2.rb | 6 ++++++
1 file changed, 6 insertions(+)

Detailed changes

sgx-bwmsgsv2.rb 🔗

@@ -450,6 +450,12 @@ module SGXbwmsgsv2
 				LOG.debug("OOB MMS details", url: un.text, body: body.to_s.strip)
 				to_catapult(s, un.text, num_dest, user_id, token, secret, usern)
 			end
+		}.catch { |e|
+			LOG.error("Error sending MMS, falling back to sending link", error: e)
+			unless body.include?(un.text)
+				s.body = body.empty? ? un.text : "#{body}\n#{un.text}"
+			end
+			to_catapult(s, nil, num_dest, user_id, token, secret, usern)
 		}
 	end