Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing message option for link_names #1278

Merged
merged 1 commit into from Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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