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

fix: ScheduleMessage not returning scheduled_message_id #1153

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ func (api *Client) ScheduleMessage(channelID, postAt string, options ...MsgOptio
// ScheduleMessageContext sends a message to a channel with a custom context.
// Slack API docs: https://api.slack.com/methods/chat.scheduleMessage
func (api *Client) ScheduleMessageContext(ctx context.Context, channelID, postAt string, options ...MsgOption) (string, string, error) {
respChannel, respTimestamp, _, err := api.SendMessageContext(
respChannel, scheduledMessageId, _, err := api.SendMessageContext(
ctx,
channelID,
MsgOptionSchedule(postAt),
MsgOptionCompose(options...),
)
return respChannel, respTimestamp, err
return respChannel, scheduledMessageId, err
}

// PostMessage sends a message to a channel.
Expand Down Expand Up @@ -214,7 +214,7 @@ func (api *Client) SendMessage(channel string, options ...MsgOption) (string, st

// SendMessageContext more flexible method for configuring messages with a custom context.
// Slack API docs: https://api.slack.com/methods/chat.postMessage
func (api *Client) SendMessageContext(ctx context.Context, channelID string, options ...MsgOption) (_channel string, _timestamp string, _text string, err error) {
func (api *Client) SendMessageContext(ctx context.Context, channelID string, options ...MsgOption) (_channel string, _timestampOrScheduledMessageId string, _text string, err error) {
var (
req *http.Request
parser func(*chatResponseFull) responseParser
Expand All @@ -238,7 +238,11 @@ func (api *Client) SendMessageContext(ctx context.Context, channelID string, opt
return "", "", "", err
}

return response.Channel, response.getMessageTimestamp(), response.Text, response.Err()
if response.ScheduledMessageID != "" {
return response.Channel, response.ScheduledMessageID, response.Text, response.Err()
} else {
return response.Channel, response.getMessageTimestamp(), response.Text, response.Err()
}
}

func redactToken(b []byte) []byte {
Expand Down