From ce744b27625b12eb4af1c3c0ce0b6644abedb387 Mon Sep 17 00:00:00 2001 From: Robby Dyer Date: Thu, 18 Apr 2024 15:10:51 -0400 Subject: [PATCH] Add missing message option for link_names --- chat.go | 8 ++++++++ chat_test.go | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/chat.go b/chat.go index 35ffbbcf..2668b382 100644 --- a/chat.go +++ b/chat.go @@ -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 diff --git a/chat_test.go b/chat_test.go index fb372259..ee93bddf 100644 --- a/chat_test.go +++ b/chat_test.go @@ -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)