From a2c826192ff3d13ee08fd141ad0a82ef8f61bbc3 Mon Sep 17 00:00:00 2001 From: VagantemNumen Date: Sat, 14 May 2016 06:15:50 +0500 Subject: [PATCH] Added check for maximum messages in the slice. If more than 100 is present send the first 100 in the request and ignore the rest. --- restapi.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/restapi.go b/restapi.go index aba74ef..6f2ace9 100644 --- a/restapi.go +++ b/restapi.go @@ -1111,7 +1111,7 @@ func (s *Session) ChannelMessageDelete(channelID, messageID string) (err error) // If only one messageID is in the slice call channelMessageDelete funciton. // If the slice is empty do nothing. // channelID : The ID of the channel for the messages to delete. -// messages : The IDs of the messages to be deleted. A slice of string IDs. +// messages : The IDs of the messages to be deleted. A slice of string IDs. A maximum of 100 messages. func (s *Session) ChannelMessagesBulkDelete(channelID string, messages []string) (err error) { if len(messages) == 0 { @@ -1123,6 +1123,10 @@ func (s *Session) ChannelMessagesBulkDelete(channelID string, messages []string) return } + if len(messages) > 100 { + messages = messages[:100] + } + data := struct { Messages []string `json:"messages"` }{messages}