Skip to content

Commit 265ee9d

Browse files
committed
Add support for "attachment" feature
This adds support for a new option, which allows servers to hint to clients that they should format the response as a separate attachment instead of returning it inline as a message. Because this is a hint, and because not all clients will support an attachment mode, clients are allowed to ignore this field for any reason. For example, Slack supports "snippets", which are arbitrary text documents sent as attachments. These don't use Slack's normal message formatting and have a larger filesize limit.
1 parent 5378b87 commit 265ee9d

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

docs/protocol-description.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ but it is important that `result` be sufficient on its own.
7070
* `image_url`: An image URL to display as the button, will generally take precedence
7171
* `command`: The command to use when the button is clicked
7272
* `image_url`: An image URL to be included with the response
73+
* `attachment`: Optional boolean which hints the recipient to format the message as an attachment, if supported by its protocol. Because this is a hint, it may be ignored by clients. If not specified, it defaults to false.
7374

7475
CRPC may also produce error JSON according to the JSON-RPC spec, consisting of
7576
an object containing an `error` object with a `message` string. This is

lib/chatops/controller.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ def jsonrpc_params
5656
params["params"] || {}
5757
end
5858

59-
def jsonrpc_success(message)
60-
jsonrpc_response :result => message.to_s
59+
def jsonrpc_success(message, options: {})
60+
response = { :result => message.to_s }
61+
# do not allow options to override message
62+
options.delete(:result)
63+
jsonrpc_response response.merge(options)
6164
end
6265
alias_method :chatop_send, :jsonrpc_success
6366

0 commit comments

Comments
 (0)