Skip to content

Commit

Permalink
Merge pull request #1278 from robbydyer/msg_opt_link_names
Browse files Browse the repository at this point in the history
Add missing message option for link_names
  • Loading branch information
parsley42 committed Apr 18, 2024
2 parents d2493fa + ce744b2 commit 3815306
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions chat.go
Expand Up @@ -696,6 +696,14 @@ func MsgOptionMetadata(metadata SlackMetadata) MsgOption {
}
}

// MsgOptionLinkNames finds and links user groups. Does not support linking individual users
func MsgOptionLinkNames(linkName bool) MsgOption {
return func(config *sendConfig) error {
config.values.Set("link_names", strconv.FormatBool(linkName))
return nil
}
}

// UnsafeMsgOptionEndpoint deliver the message to the specified endpoint.
// NOTE: USE AT YOUR OWN RISK: No issues relating to the use of this Option
// will be supported by the library, it is subject to change without notice that
Expand Down
22 changes: 22 additions & 0 deletions chat_test.go
Expand Up @@ -185,6 +185,28 @@ func TestPostMessage(t *testing.T) {
"user_auth_message": []string{"Please!"},
},
},
"LinkNames true": {
endpoint: "/chat.postMessage",
opt: []MsgOption{
MsgOptionLinkNames(true),
},
expected: url.Values{
"channel": []string{"CXXX"},
"token": []string{"testing-token"},
"link_names": []string{"true"},
},
},
"LinkNames false": {
endpoint: "/chat.postMessage",
opt: []MsgOption{
MsgOptionLinkNames(false),
},
expected: url.Values{
"channel": []string{"CXXX"},
"token": []string{"testing-token"},
"link_names": []string{"false"},
},
},
}

once.Do(startServer)
Expand Down

0 comments on commit 3815306

Please sign in to comment.