diff --git a/sgx-catapult.rb b/sgx-catapult.rb index d5b87fde7d380d22ff2f4d3015643098850001df..fb6e6db490b712379f356aa919221d70c985f1d8 100755 --- a/sgx-catapult.rb +++ b/sgx-catapult.rb @@ -215,6 +215,13 @@ module SGXcatapult end def self.to_catapult(s, murl, num_dest, user_id, token, secret, usern) + body = s.respond_to?(:body) ? s.body : '' + if murl.to_s.empty? && body.to_s.strip.empty? + return EMPromise.reject( + [:modify, 'policy-violation'] + ) + end + extra = if murl { media: murl @@ -234,7 +241,7 @@ module SGXcatapult JSON.dump(extra.merge( from: usern, to: num_dest, - text: s.respond_to?(:body) ? s.body : '', + text: body, tag: # callbacks need id and resourcepart WEBrick::HTTPUtils.escape(s.id.to_s) + @@ -279,7 +286,7 @@ module SGXcatapult } end - message :chat?, :body do |m| + message :body do |m| EMPromise.all([ validate_num(m.to.node), fetch_catapult_cred_for(m.from)