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 include_num_members support to conversation.info request #989

Merged
merged 7 commits into from Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 7 additions & 1 deletion conversation.go
Expand Up @@ -5,6 +5,8 @@ import (
"net/url"
"strconv"
"strings"

"github.com/pkg/errors"
Yohan460 marked this conversation as resolved.
Show resolved Hide resolved
)

// Conversation is the foundation for IM and BaseGroupConversation
Expand Down Expand Up @@ -372,7 +374,11 @@ func (api *Client) GetConversationInfo(input *GetConversationInfoInput) (*Channe
// GetConversationInfoContext retrieves information about a conversation with a custom context
func (api *Client) GetConversationInfoContext(ctx context.Context, input *GetConversationInfoInput) (*Channel, error) {
if input == nil {
input = &GetConversationInfoInput{}
return nil, errors.New("GetConversationInfoInput must not be nil")
}

if input.ChannelID == "" {
return nil, errors.New("ChannelID must be defined")
}

values := url.Values{
Expand Down
22 changes: 22 additions & 0 deletions conversation_test.go
Expand Up @@ -413,6 +413,28 @@ func TestGetConversationInfo(t *testing.T) {
}
}

func TestGetConversationInfoNilError(t *testing.T) {
http.HandleFunc("/conversations.info", okChannelJsonHandler)
once.Do(startServer)
api := New("testing-token", OptionAPIURL("http://"+serverAddr+"/"))
_, err := api.GetConversationInfo(nil)
if err == nil {
t.Errorf("Unexpected pass where there should have been nil input error")
return
}
}

func TestGetConversationInfoMissingChannelError(t *testing.T) {
http.HandleFunc("/conversations.info", okChannelJsonHandler)
Yohan460 marked this conversation as resolved.
Show resolved Hide resolved
once.Do(startServer)
api := New("testing-token", OptionAPIURL("http://"+serverAddr+"/"))
_, err := api.GetConversationInfo(&GetConversationInfoInput{})
if err == nil {
t.Errorf("Unexpected pass where there should have been missing channel error")
return
}
}

func leaveConversationHandler(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "application/json")
response, _ := json.Marshal(struct {
Expand Down