-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add attachments support for Slack::Web::Api::Endpoints::Chat.chat_update
- Loading branch information
Showing
5 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
lib/slack/web/api/patches/chat.3.update-attachments-support.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb | ||
index 0db7e67..1c3b2ee 100644 | ||
--- a/lib/slack/web/api/endpoints/chat.rb | ||
+++ b/lib/slack/web/api/endpoints/chat.rb | ||
@@ -82,8 +82,14 @@ module Slack | ||
def chat_update(options = {}) | ||
throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil? | ||
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil? | ||
- throw ArgumentError.new('Required arguments :text missing') if options[:text].nil? | ||
+ throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].nil? | ||
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel] | ||
+ # 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.update', options) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters