diff --git a/sgx-bwmsgsv2.rb b/sgx-bwmsgsv2.rb index b5705ee3eb37ee12df28016d4b77ebd1efda63e7..325f2259b67f64869e318107d2bac1c7dbf59c3c 100755 --- a/sgx-bwmsgsv2.rb +++ b/sgx-bwmsgsv2.rb @@ -303,13 +303,14 @@ module SGXbwmsgsv2 body = s.respond_to?(:body) ? s.body : '' EM::HttpRequest.new(un.text, tls: { verify_peer: true }).head.then { |http| + # If content is too large, or MIME type is not supported, place the link inside the body and do not send MMS. if http.response_header["CONTENT_LENGTH"].to_i > 3500000 || !MMS_MIME_TYPES.include?(http.response_header["CONTENT_TYPE"]) 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) - else + else # If size is less than ~3.5MB, strip the link from the body and attach media in the body. # some clients send URI in both body & so delete s.body = body.sub(/\s*#{Regexp.escape(un.text)}\s*$/, '')