Skip to content

Commit

Permalink
Merge branch 'master' into feat/workflow-triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzoaiello authored Nov 14, 2024
2 parents c6e9139 + e764011 commit 8b614ad
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 113 deletions.
103 changes: 0 additions & 103 deletions CHANGELOG.md

This file was deleted.

40 changes: 40 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Contributing Guide

Welcome! We are glad that you want to contribute to our project! 💖

There are a just a few small guidelines you ask everyone to follow to make things a bit smoother and more consistent.

## Opening Pull Requests

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.

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.

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.

4. Run `make pr-prep` to format your code and check that it passes all tests and linters.

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.

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`.

## Code Comments

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:

```go
// PostMessage sends a message to a channel.
//
// Slack API docs: https://api.dev.slack.com/methods/chat.postMessage
func (api *Client) PostMessage(ctx context.Context, input PostMesssageInput) (PostMesssageOutput, error) {
...
}
```

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.

After the description comes a link to the Slack API documentation.

## Other notes on code organization

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).
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ a fully managed way.
There is currently no major version released.
Therefore, minor version releases may include backward incompatible changes.

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.
See [Releases](https://github.com/slack-go/slack/releases) for more information about the changes.

## Installing

Expand Down
3 changes: 0 additions & 3 deletions TODO.txt

This file was deleted.

4 changes: 4 additions & 0 deletions assistant.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ func (api *Client) SetAssistantThreadsSuggestedPromptsContext(ctx context.Contex
values.Add("thread_ts", params.ThreadTS)
}

values.Add("channel_id", params.ChannelID)

// Send Prompts as JSON
prompts, err := json.Marshal(params.Prompts)
if err != nil {
Expand Down Expand Up @@ -98,6 +100,8 @@ func (api *Client) SetAssistantThreadsStatusContext(ctx context.Context, params
values.Add("thread_ts", params.ThreadTS)
}

values.Add("channel_id", params.ChannelID)

// Always send the status parameter, if empty, it will clear any existing status
values.Add("status", params.Status)

Expand Down
2 changes: 1 addition & 1 deletion block_rich_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func NewRichTextSectionUserElement(userID string, style *RichTextSectionTextStyl
type RichTextSectionEmojiElement struct {
Type RichTextSectionElementType `json:"type"`
Name string `json:"name"`
SkinTone int `json:"skin_tone"`
SkinTone int `json:"skin_tone,omitempty"`
Unicode string `json:"unicode,omitempty"`
Style *RichTextSectionTextStyle `json:"style,omitempty"`
}
Expand Down
14 changes: 13 additions & 1 deletion block_rich_text_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ func TestRichTextSection_UnmarshalJSON(t *testing.T) {
},
nil,
},
{
[]byte(`{"type": "rich_text_section","elements":[{"type": "emoji","name": "+1"}]}`),
RichTextSection{
Type: RTESection,
Elements: []RichTextSectionElement{
&RichTextSectionEmojiElement{Type: RTSEEmoji, Name: "+1"},
},
},
nil,
},
{
[]byte(`{"type": "rich_text_section","elements":[{"type": "emoji","name": "+1","unicode": "1f44d-1f3fb","skin_tone": 2}]}`),
RichTextSection{
Expand Down Expand Up @@ -299,7 +309,7 @@ func TestRichTextList_UnmarshalJSON(t *testing.T) {

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

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

Expand Down
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

0 comments on commit 8b614ad

Please sign in to comment.