Sha256: 9bfc481477b4451d9c08bbdfba0b4925f670bba44755a868cee59ec1681a61ee

Contents?: true

Size: 915 Bytes

Versions: 36

Compression:

Stored size: 915 Bytes

Contents

diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb
index 1f7a8d7..89b1562 100644
--- a/lib/slack/web/api/endpoints/chat.rb
+++ b/lib/slack/web/api/endpoints/chat.rb
@@ -50,6 +50,12 @@ module Slack
           def chat_postMessage(options = {})
             throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
             throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].nil?
+            # attachments must be passed as an encoded JSON string
+            if options.key?(:attachments)
+              attachments = options[:attachments]
+              attachments = JSON.dump(attachments) unless attachments.is_a?(String)
+              options = options.merge(attachments: attachments)
+            end
             post('chat.postMessage', options)
           end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
slack-ruby-client-0.7.8 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.7.7 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.7.6 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.7.5 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.7.4 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.7.3 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.7.2 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.7.1 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.7.0 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.6.0 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.5.4 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.5.3 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.5.2 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.5.1 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.5.0 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.4.0 lib/slack/web/api/patches/chat.2.attachments-json.patch