Skip to content

Commit a9a75e2

Browse files
Fixed attachment code.
1 parent 2994d7f commit a9a75e2

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/send.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ end
2727
Takes in a string of data and the endpoint url and returns the HTTP response.
2828
The response will be "ok" if the request is sent successfully.
2929
"""
30-
function sendattachmenttoslack(data::String, user_endpoint::String)
30+
function sendattachmenttoslack(data, user_endpoint::String)
3131
HTTP.setuseragent!("HTTP.jl")
3232

3333

34-
params = Dict("attachments"=>"$(data)")
34+
params = data
3535
base_url = "https://hooks.slack.com"
3636

3737
endpoint = user_endpoint

test/runtests.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@ using Test
33

44
endpoint = "/services/TQVJBU534/BR8C1LMPS/42thawJz34SWSgZCpniyLBSE"
55
data = "Hello World"
6+
attachment = Dict("attachments" => [Dict("fallback" => "Required plain-text summary of the attachment",
7+
"color" => "#36a64f",
8+
"pretext" => "Optional text that appears above the attachment block",
9+
"author_name" => "Bobby Tables",
10+
"author_link" => "http://flickr.com/bobby/",
11+
"author_icon" => "http://flickr.com/icons/bobby.jpg",
12+
"title" => "Slack API Documentation",
13+
"title_link" => "https://api.slack.com/",
14+
"text" => "Optional text that appears within the attachment"
15+
)])
616

717
response = sendtoslack(data, endpoint)
818
@test response == "ok"
19+
20+
response2 = sendattachmenttoslack(attachment, endpoint)
21+
@test response2 == "ok"

0 commit comments

Comments
 (0)