Skip to content

Commit 1002a1a

Browse files
authored
Merge pull request #37 from github/add_attachment_support
Add support for "attachment" feature
2 parents 5378b87 + baac38a commit 1002a1a

2 files changed

Lines changed: 8 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: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,13 @@ def jsonrpc_params
5656
params["params"] || {}
5757
end
5858

59-
def jsonrpc_success(message)
60-
jsonrpc_response :result => message.to_s
59+
# `options` supports any of the optional fields documented
60+
# in the [protocol](../../docs/protocol-description.md).
61+
def jsonrpc_success(message, options: {})
62+
response = { :result => message.to_s }
63+
# do not allow options to override message
64+
options.delete(:result)
65+
jsonrpc_response response.merge(options)
6166
end
6267
alias_method :chatop_send, :jsonrpc_success
6368

0 commit comments

Comments
 (0)