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.14.6 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.14.5 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-bhe-0.5.5 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-bhe-0.5.4 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.14.4 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.14.3 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.14.2 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.14.1 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.14.0 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.13.1 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.13.0 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.12.0 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.11.1 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.11.0 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.10.0 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.9.1 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.9.0 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.8.1 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.8.0 lib/slack/web/api/patches/chat.2.attachments-json.patch
slack-ruby-client-0.7.9 lib/slack/web/api/patches/chat.2.attachments-json.patch