Skip to content

Commit 8b614ad

Browse files
Merge branch 'master' into feat/workflow-triggers
2 parents c6e9139 + e764011 commit 8b614ad

File tree

8 files changed

+67
-113
lines changed

8 files changed

+67
-113
lines changed

CHANGELOG.md

Lines changed: 0 additions & 103 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Contributing Guide
2+
3+
Welcome! We are glad that you want to contribute to our project! 💖
4+
5+
There are a just a few small guidelines you ask everyone to follow to make things a bit smoother and more consistent.
6+
7+
## Opening Pull Requests
8+
9+
1. It's generally best to start by opening a new issue describing the bug or feature you're intending to fix. Even if you think it's relatively minor, it's helpful to know what people are working on. Mention in the initial issue that you are planning to work on that bug or feature so that it can be assigned to you.
10+
11+
2. Follow the normal process of [forking](https://help.github.com/articles/fork-a-repo) the project, and set up a new branch to work in. It's important that each group of changes be done in separate branches in order to ensure that a pull request only includes the commits related to that bug or feature.
12+
13+
3. Any significant changes should almost always be accompanied by tests. The project already has some test coverage, so look at some of the existing tests if you're unsure how to go about it.
14+
15+
4. Run `make pr-prep` to format your code and check that it passes all tests and linters.
16+
17+
5. Do your best to have [well-formed commit messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) for each change. This provides consistency throughout the project, and ensures that commit messages are able to be formatted properly by various git tools. _Pull Request Titles_ should generally follow the [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) format to ease the release note process when cutting releases.
18+
19+
6. Finally, push the commits to your fork and submit a [pull request](https://help.github.com/articles/creating-a-pull-request). NOTE: Please do not use force-push on PRs in this repo, as it makes it more difficult for reviewers to see what has changed since the last code review. We always perform "squash and merge" actions on PRs in this repo, so it doesn't matter how many commits your PR has, as they will end up being a single commit after merging. This is done to make a much cleaner `git log` history and helps to find regressions in the code using existing tools such as `git bisect`.
20+
21+
## Code Comments
22+
23+
Every exported method needs to have code comments that follow [Go Doc Comments](https://go.dev/doc/comment). A typical method's comments will look like this:
24+
25+
```go
26+
// PostMessage sends a message to a channel.
27+
//
28+
// Slack API docs: https://api.dev.slack.com/methods/chat.postMessage
29+
func (api *Client) PostMessage(ctx context.Context, input PostMesssageInput) (PostMesssageOutput, error) {
30+
...
31+
}
32+
```
33+
34+
The first line is the name of the method followed by a short description. This could also be a longer description if needed, but there is no need to repeat any details that are documented in Slack's documentation because users are expected to follow the documentation links to learn more.
35+
36+
After the description comes a link to the Slack API documentation.
37+
38+
## Other notes on code organization
39+
40+
Currently, everything is defined in the main `slack` package, with API methods group separate files by the [Slack API Method Groupings](https://api.dev.slack.com/methods).

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ a fully managed way.
1515
There is currently no major version released.
1616
Therefore, minor version releases may include backward incompatible changes.
1717

18-
See [CHANGELOG.md](https://github.com/slack-go/slack/blob/master/CHANGELOG.md) or [Releases](https://github.com/slack-go/slack/releases) for more information about the changes.
18+
See [Releases](https://github.com/slack-go/slack/releases) for more information about the changes.
1919

2020
## Installing
2121

TODO.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

assistant.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ func (api *Client) SetAssistantThreadsSuggestedPromptsContext(ctx context.Contex
6060
values.Add("thread_ts", params.ThreadTS)
6161
}
6262

63+
values.Add("channel_id", params.ChannelID)
64+
6365
// Send Prompts as JSON
6466
prompts, err := json.Marshal(params.Prompts)
6567
if err != nil {
@@ -98,6 +100,8 @@ func (api *Client) SetAssistantThreadsStatusContext(ctx context.Context, params
98100
values.Add("thread_ts", params.ThreadTS)
99101
}
100102

103+
values.Add("channel_id", params.ChannelID)
104+
101105
// Always send the status parameter, if empty, it will clear any existing status
102106
values.Add("status", params.Status)
103107

block_rich_text.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ func NewRichTextSectionUserElement(userID string, style *RichTextSectionTextStyl
340340
type RichTextSectionEmojiElement struct {
341341
Type RichTextSectionElementType `json:"type"`
342342
Name string `json:"name"`
343-
SkinTone int `json:"skin_tone"`
343+
SkinTone int `json:"skin_tone,omitempty"`
344344
Unicode string `json:"unicode,omitempty"`
345345
Style *RichTextSectionTextStyle `json:"style,omitempty"`
346346
}

block_rich_text_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,16 @@ func TestRichTextSection_UnmarshalJSON(t *testing.T) {
187187
},
188188
nil,
189189
},
190+
{
191+
[]byte(`{"type": "rich_text_section","elements":[{"type": "emoji","name": "+1"}]}`),
192+
RichTextSection{
193+
Type: RTESection,
194+
Elements: []RichTextSectionElement{
195+
&RichTextSectionEmojiElement{Type: RTSEEmoji, Name: "+1"},
196+
},
197+
},
198+
nil,
199+
},
190200
{
191201
[]byte(`{"type": "rich_text_section","elements":[{"type": "emoji","name": "+1","unicode": "1f44d-1f3fb","skin_tone": 2}]}`),
192202
RichTextSection{
@@ -299,7 +309,7 @@ func TestRichTextList_UnmarshalJSON(t *testing.T) {
299309

300310
func TestRichTextQuote_Marshal(t *testing.T) {
301311
t.Run("rich_text_section", func(t *testing.T) {
302-
const rawRSE = "{\"type\":\"rich_text_section\",\"elements\":[{\"type\":\"text\",\"text\":\"Some Text\"}]}"
312+
const rawRSE = "{\"type\":\"rich_text_section\",\"elements\":[{\"type\":\"text\",\"text\":\"Some Text\"},{\"type\":\"emoji\",\"name\":\"+1\"},{\"type\":\"emoji\",\"name\":\"+1\",\"skin_tone\":2}]}"
303313

304314
var got RichTextSection
305315
if err := json.Unmarshal([]byte(rawRSE), &got); err != nil {
@@ -309,6 +319,8 @@ func TestRichTextQuote_Marshal(t *testing.T) {
309319
Type: RTESection,
310320
Elements: []RichTextSectionElement{
311321
&RichTextSectionTextElement{Type: RTSEText, Text: "Some Text"},
322+
&RichTextSectionEmojiElement{Type: RTSEEmoji, Name: "+1"},
323+
&RichTextSectionEmojiElement{Type: RTSEEmoji, Name: "+1", SkinTone: 2},
312324
},
313325
}
314326

chat.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ func (api *Client) ScheduleMessage(channelID, postAt string, options ...MsgOptio
116116
// ScheduleMessageContext sends a message to a channel with a custom context.
117117
// Slack API docs: https://api.slack.com/methods/chat.scheduleMessage
118118
func (api *Client) ScheduleMessageContext(ctx context.Context, channelID, postAt string, options ...MsgOption) (string, string, error) {
119-
respChannel, respTimestamp, _, err := api.SendMessageContext(
119+
respChannel, scheduledMessageId, _, err := api.SendMessageContext(
120120
ctx,
121121
channelID,
122122
MsgOptionSchedule(postAt),
123123
MsgOptionCompose(options...),
124124
)
125-
return respChannel, respTimestamp, err
125+
return respChannel, scheduledMessageId, err
126126
}
127127

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

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

241-
return response.Channel, response.getMessageTimestamp(), response.Text, response.Err()
241+
if response.ScheduledMessageID != "" {
242+
return response.Channel, response.ScheduledMessageID, response.Text, response.Err()
243+
} else {
244+
return response.Channel, response.getMessageTimestamp(), response.Text, response.Err()
245+
}
242246
}
243247

244248
func redactToken(b []byte) []byte {

0 commit comments

Comments
 (0)