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

Gautam/sync upstream #11

Merged
merged 39 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c66312a
Revert "go slackevents: add support for team domain changed event"
gautamr95 Dec 13, 2024
f48ba85
Revert "add: slackevents channel_shared event"
gautamr95 Dec 13, 2024
8f96a25
Fix UploadFileV2 when using text content (#1291)
calebmckay Jun 6, 2024
02c45f8
Add UnfurlLinks and UnfurlMedia to WebhookMessage
Jun 22, 2023
564a12a
Trigger GitHub Actions
lorenzoaiello Jul 14, 2024
6f67fb4
chore: slice replace loop (#1211)
testwill Jul 15, 2024
38468dd
Add isReadOnly property to Conversation struct (#1232)
GGonryun Jul 15, 2024
c8f9446
chore: make channel optional on `UploadFileV2` (#1293)
0xdeafcafe Jul 15, 2024
8c413e1
chore: Adding Deprecation Notice for files.upload (#1300)
lorenzoaiello Jul 15, 2024
2f9d3f4
ci: Adding Go Test Coverage for 1.21 and 1.22 (#1298)
lorenzoaiello Jul 15, 2024
2488c82
docs: Updating Inline Docs and API References (#1299)
lorenzoaiello Jul 15, 2024
da3dfb5
docs: Add an example demonstrating correct usage of GetUsersPaginated…
adamrothman Jul 15, 2024
2e9f9de
docs: Adding an example for AddRemoteFile and DeleteFile (#1303)
lorenzoaiello Jul 15, 2024
4a4f501
docs: Adding an example for ConversationHistory (#1302)
lorenzoaiello Jul 15, 2024
f15c155
slackevents: support metadata in MessageEvent (#1307)
rfratto Jul 20, 2024
8e2f298
chore: replace ioutil with io or os package (#1310)
nakamasato Aug 15, 2024
f22de54
add file access field to file struct for slackevents (#1312)
zFlabmonsta Aug 15, 2024
d4fc349
Add slack_file to image block (#1311)
rhysm Aug 15, 2024
1a9de41
feat: Events api reconcilation (#1306)
Aryakoste Aug 15, 2024
e52c97a
feat: Add support for parsing AppRateLimited events (#1308)
nemuvski Aug 15, 2024
3fe2f28
feat: Add Properties.Canvas to Channel (#1228)
ku Aug 15, 2024
12169c7
fix: create multipart form when multipart request (#1117)
EkeMinusYou Aug 15, 2024
e7912b3
feat: Add go version 1.23 to test matrix (test.yml) (#1315)
nemuvski Aug 20, 2024
3b4335a
ci: Bump GitHub Actions to Latest Versions
shogo82148 Aug 20, 2024
33911b4
fix: fix deprecated comment for UploadFile and UploadFileContext (#1316)
shogo82148 Aug 21, 2024
94842bf
Support publishing a messge to a specific thread (#1309)
Nikolo Sep 17, 2024
9f8e4a5
fix: Add required `format` field to rich text date blocks (#1317)
luke-josh Sep 17, 2024
8355e5a
fix: Updated RichTextInputBlockElement InitialValue data type (#1320)
Manjish Sep 19, 2024
d06028e
feat: Add support for unicode parameter in emoji type of rich text bl…
YutoKashiwagi Sep 19, 2024
6191bc9
Add endpoints for `calls.*` apis and `Type: call` in blockkit (#1190)
winston-stripe Oct 14, 2024
c1e7a83
feat: Add Convenience Methods to Block Elements (#1279)
obed-sj Oct 14, 2024
c3b31dc
feat: Add functions.completeError and functions.completeSuccess (#1328)
gideonw Oct 14, 2024
17f827a
feat: Add support for external_limited option of inviteShared (#1330)
bamo Oct 14, 2024
7ff6c6d
feat: Add support for Canvas API methods (#1334)
jarospisak-unity Oct 14, 2024
a24b24b
feat: Slack AI & Assistants Compatibility (#1331)
MattDavisRV Nov 6, 2024
59a58da
fix: Assistant Prompts and Status, send channel_id with request (#1344)
MattDavisRV Nov 12, 2024
c42c66d
fix: Don't require `skin_tone` for rich text emoji element (#1341)
calebmckay Nov 12, 2024
2a88f52
fix: ScheduleMessage not returning scheduled_message_id (#1153)
hussachai Nov 14, 2024
0b7ce9f
chore: Contributing Guide - Codification of Project Norms (#1340)
lorenzoaiello Nov 14, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/stale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@1160a2240286f5da8ec72b1c0816ce2481aabf84 # v8.0.0
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0
with:
any-of-labels: 'feedback given'
days-before-stale: 45
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ jobs:
- '1.18'
- '1.19'
- '1.20'
- '1.21'
- '1.22'
- '1.23'
name: test go-${{ matrix.go }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: run test
Expand All @@ -29,14 +32,14 @@ jobs:
runs-on: ubuntu-22.04
name: lint
steps:
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20'
cache: false
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: golangci-lint
uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 # v3.4.0
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
with:
version: v1.52.2
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.

10 changes: 9 additions & 1 deletion apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ type EventAuthorization struct {
IsEnterpriseInstall bool `json:"is_enterprise_install"`
}

// ListEventAuthorizations lists authed users and teams for the given event_context.
// You must provide an app-level token to the client using OptionAppLevelToken.
// For more details, see ListEventAuthorizationsContext documentation.
func (api *Client) ListEventAuthorizations(eventContext string) ([]EventAuthorization, error) {
return api.ListEventAuthorizationsContext(context.Background(), eventContext)
}

// ListEventAuthorizationsContext lists authed users and teams for the given event_context. You must provide an app-level token to the client using OptionAppLevelToken. More info: https://api.slack.com/methods/apps.event.authorizations.list
// ListEventAuthorizationsContext lists authed users and teams for the given event_context with a custom context.
// Slack API docs: https://api.slack.com/methods/apps.event.authorizations.list
func (api *Client) ListEventAuthorizationsContext(ctx context.Context, eventContext string) ([]EventAuthorization, error) {
resp := &listEventAuthorizationsResponse{}

Expand All @@ -43,10 +47,14 @@ func (api *Client) ListEventAuthorizationsContext(ctx context.Context, eventCont
return resp.Authorizations, nil
}

// UninstallApp uninstalls your app from a workspace.
// For more details, see UninstallAppContext documentation.
func (api *Client) UninstallApp(clientID, clientSecret string) error {
return api.UninstallAppContext(context.Background(), clientID, clientSecret)
}

// UninstallAppContext uninstalls your app from a workspace with a custom context.
// Slack API docs: https://api.slack.com/methods/apps.uninstall
func (api *Client) UninstallAppContext(ctx context.Context, clientID, clientSecret string) error {
values := url.Values{
"client_id": {clientID},
Expand Down
157 changes: 157 additions & 0 deletions assistant.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
package slack

import (
"context"
"encoding/json"
"net/url"
)

// AssistantThreadSetStatusParameters are the parameters for AssistantThreadSetStatus
type AssistantThreadsSetStatusParameters struct {
ChannelID string `json:"channel_id"`
Status string `json:"status"`
ThreadTS string `json:"thread_ts"`
}

// AssistantThreadSetTitleParameters are the parameters for AssistantThreadSetTitle
type AssistantThreadsSetTitleParameters struct {
ChannelID string `json:"channel_id"`
ThreadTS string `json:"thread_ts"`
Title string `json:"title"`
}

// AssistantThreadSetSuggestedPromptsParameters are the parameters for AssistantThreadSetSuggestedPrompts
type AssistantThreadsSetSuggestedPromptsParameters struct {
Title string `json:"title"`
ChannelID string `json:"channel_id"`
ThreadTS string `json:"thread_ts"`
Prompts []AssistantThreadsPrompt `json:"prompts"`
}

// AssistantThreadPrompt is a suggested prompt for a thread
type AssistantThreadsPrompt struct {
Title string `json:"title"`
Message string `json:"message"`
}

// AssistantThreadSetSuggestedPrompts sets the suggested prompts for a thread
func (p *AssistantThreadsSetSuggestedPromptsParameters) AddPrompt(title, message string) {
p.Prompts = append(p.Prompts, AssistantThreadsPrompt{
Title: title,
Message: message,
})
}

// SetAssistantThreadsSugesstedPrompts sets the suggested prompts for a thread
// @see https://api.slack.com/methods/assistant.threads.setSuggestedPrompts
func (api *Client) SetAssistantThreadsSuggestedPrompts(params AssistantThreadsSetSuggestedPromptsParameters) (err error) {
return api.SetAssistantThreadsSuggestedPromptsContext(context.Background(), params)
}

// SetAssistantThreadSuggestedPromptsContext sets the suggested prompts for a thread with a custom context
// @see https://api.slack.com/methods/assistant.threads.setSuggestedPrompts
func (api *Client) SetAssistantThreadsSuggestedPromptsContext(ctx context.Context, params AssistantThreadsSetSuggestedPromptsParameters) (err error) {

values := url.Values{
"token": {api.token},
}

if params.ThreadTS != "" {
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 {
return err
}

values.Add("prompts", string(prompts))

response := struct {
SlackResponse
}{}

err = api.postMethod(ctx, "assistant.threads.setSuggestedPrompts", values, &response)
if err != nil {
return
}

return response.Err()
}

// SetAssistantThreadStatus sets the status of a thread
// @see https://api.slack.com/methods/assistant.threads.setStatus
func (api *Client) SetAssistantThreadsStatus(params AssistantThreadsSetStatusParameters) (err error) {
return api.SetAssistantThreadsStatusContext(context.Background(), params)
}

// SetAssistantThreadStatusContext sets the status of a thread with a custom context
// @see https://api.slack.com/methods/assistant.threads.setStatus
func (api *Client) SetAssistantThreadsStatusContext(ctx context.Context, params AssistantThreadsSetStatusParameters) (err error) {

values := url.Values{
"token": {api.token},
}

if params.ThreadTS != "" {
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)

response := struct {
SlackResponse
}{}

err = api.postMethod(ctx, "assistant.threads.setStatus", values, &response)
if err != nil {
return
}

return response.Err()
}

// SetAssistantThreadsTitle sets the title of a thread
// @see https://api.slack.com/methods/assistant.threads.setTitle
func (api *Client) SetAssistantThreadsTitle(params AssistantThreadsSetTitleParameters) (err error) {
return api.SetAssistantThreadsTitleContext(context.Background(), params)
}

// SetAssistantThreadsTitleContext sets the title of a thread with a custom context
// @see https://api.slack.com/methods/assistant.threads.setTitle
func (api *Client) SetAssistantThreadsTitleContext(ctx context.Context, params AssistantThreadsSetTitleParameters) (err error) {

values := url.Values{
"token": {api.token},
}

if params.ChannelID != "" {
values.Add("channel_id", params.ChannelID)
}

if params.ThreadTS != "" {
values.Add("thread_ts", params.ThreadTS)
}

if params.Title != "" {
values.Add("title", params.Title)
}

response := struct {
SlackResponse
}{}

err = api.postMethod(ctx, "assistant.threads.setTitle", values, &response)
if err != nil {
return
}

return response.Err()

}
Loading