Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: slack-go/slack
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.12.3
Choose a base ref
...
head repository: slack-go/slack
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.12.4
Choose a head ref

Commits on Dec 13, 2022

  1. Copy the full SHA
    b54bd85 View commit details

Commits on Dec 25, 2022

  1. Copy the full SHA
    7589264 View commit details
  2. Change comments at L183 to suggestion

    Co-authored-by: Naoki Kanatani <k12naoki@gmail.com>
    KouWakai and kanata2 authored Dec 25, 2022
    Copy the full SHA
    c4f3ebe View commit details
  3. Change http response StatusUnauthorized at L188 to StatusInternalServ…

    …erError
    
    Co-authored-by: Naoki Kanatani <k12naoki@gmail.com>
    KouWakai and kanata2 authored Dec 25, 2022
    Copy the full SHA
    824342e View commit details

Commits on Jul 10, 2023

  1. Copy the full SHA
    7302609 View commit details

Commits on Aug 15, 2023

  1. Copy the full SHA
    dc27c00 View commit details
  2. Copy the full SHA
    311ff6a View commit details
  3. Copy the full SHA
    7b783e6 View commit details
  4. Copy the full SHA
    6fe1bec View commit details

Commits on Aug 19, 2023

  1. add time pkg

    KouWakai authored Aug 19, 2023
    Copy the full SHA
    cf4e8bc View commit details

Commits on Aug 29, 2023

  1. Merge pull request #1212 from testwill/fmt

    chore: unnecessary use of fmt.Sprintf
    parsley42 authored Aug 29, 2023
    Copy the full SHA
    4c00dbd View commit details

Commits on Sep 10, 2023

  1. 4
    Copy the full SHA
    b13e91d View commit details

Commits on Sep 20, 2023

  1. Copy the full SHA
    b801caa View commit details

Commits on Oct 16, 2023

  1. Add support for Rich Text Input

    Peiman Jafari committed Oct 16, 2023
    Copy the full SHA
    e439902 View commit details

Commits on Oct 21, 2023

  1. Add Video Block (#1210)

    Add support for Video Blocks
    
    Ref. https://api.slack.com/reference/block-kit/blocks#video
    
    cf. #1205
    
    ---------
    
    Co-authored-by: David Parsley <parsley@linuxjedi.org>
    Co-authored-by: Ben Bourdin <ben-bourdin451@users.noreply.github.com>
    3 people authored Oct 21, 2023
    Copy the full SHA
    e715221 View commit details

Commits on Oct 24, 2023

  1. Add rich_text_input block conv

    Peiman Jafari committed Oct 24, 2023
    Copy the full SHA
    1b0eb7d View commit details

Commits on Nov 6, 2023

  1. Copy the full SHA
    f2fe7b3 View commit details
  2. Copy the full SHA
    311e30d View commit details
  3. Copy the full SHA
    8019a9a View commit details

Commits on Nov 14, 2023

  1. Copy the full SHA
    fd060b6 View commit details
  2. Add support for Indent field

    Co-authored-by: SimonLiuRoblox <84740141+SimonLiuRoblox@users.noreply.github.com>
    daniel-pieper-personio and SimonLiuRoblox committed Nov 14, 2023
    Copy the full SHA
    0f23d87 View commit details

Commits on Dec 20, 2023

  1. Copy the full SHA
    2a4205d View commit details

Commits on Dec 21, 2023

  1. Copy the full SHA
    59faa0e View commit details

Commits on Jan 22, 2024

  1. add connected_team_ids, shared_team_ids, internal_team_ids, is_global…

    …_shared field to conversation
    zFlabmonsta committed Jan 22, 2024
    Copy the full SHA
    4160354 View commit details

Commits on Jan 29, 2024

  1. Merge pull request #1253 from zFlabmonsta/master

    Add connected_team_ids optional field to Conversation
    parsley42 authored Jan 29, 2024
    Copy the full SHA
    07c76ba View commit details

Commits on Jan 30, 2024

  1. Merge pull request #1227 from invzhi/master

    Add blocks in slackevents.MessageEvent
    parsley42 authored Jan 30, 2024
    Copy the full SHA
    86cd1bd View commit details

Commits on Feb 1, 2024

  1. fix: expose is_enterprise_install field

    Alvin See committed Feb 1, 2024
    Copy the full SHA
    0ecd566 View commit details
  2. Copy the full SHA
    e821170 View commit details

Commits on Feb 2, 2024

  1. Copy the full SHA
    cd8ca23 View commit details
  2. Fix linter

    daniel-pieper-personio committed Feb 2, 2024
    Copy the full SHA
    bc6223b View commit details

Commits on Feb 7, 2024

  1. Fix: always add context to errors during block serde

    Signed-off-by: kayos@tcp.direct <kayos@tcp.direct>
    yunginnanet committed Feb 7, 2024
    Copy the full SHA
    53178c2 View commit details

Commits on Feb 9, 2024

  1. Merge pull request #1155 from daniel-pieper-personio/richtext-list

    Add support for Rich Text Lists
    parsley42 authored Feb 9, 2024
    Copy the full SHA
    f6b09b8 View commit details
  2. Add WithURL support for ButtonBlockElement

    Josh Branham committed Feb 9, 2024
    Copy the full SHA
    e743e65 View commit details

Commits on Feb 10, 2024

  1. Merge pull request #1240 from peimanja/rich-text-input

    Add support for Rich Text Input
    parsley42 authored Feb 10, 2024
    Copy the full SHA
    9d132f3 View commit details
  2. Merge pull request #1259 from yunginnanet/master

    Fix: always add context to errors during block serde
    parsley42 authored Feb 10, 2024
    Copy the full SHA
    15f367e View commit details
  3. Merge pull request #1256 from IbirbyZh/add-edited-to-the-app-mention-…

    …event
    
    Edited field in the app mention event
    parsley42 authored Feb 10, 2024
    Copy the full SHA
    687e2d3 View commit details
  4. Merge pull request #1255 from 7ail/asee/is_enterprise_install

    Expose is_enterprise_install field
    parsley42 authored Feb 10, 2024
    Copy the full SHA
    4c9f181 View commit details
  5. Merge pull request #1250 from joshbranham/new-button-block-url

    feat: Add the ability to set `URL` on `NewButtonBlockElement` via `.WithURL()`
    parsley42 authored Feb 10, 2024
    Copy the full SHA
    c4923b2 View commit details
  6. Merge pull request #1249 from elct9620/add-file_input-element

    Add block element type FileInput
    parsley42 authored Feb 10, 2024
    Copy the full SHA
    ceb2250 View commit details
  7. Merge pull request #1242 from danielmichaels/openid-connect

    Openid connect
    parsley42 authored Feb 10, 2024
    Copy the full SHA
    9cc451b View commit details
  8. Merge pull request #1225 from hussachai/enterprise_install

    Add is_enterprise_install flag for org wide installation support
    parsley42 authored Feb 10, 2024
    Copy the full SHA
    fd5d171 View commit details
  9. Merge pull request #1142 from KouWakai/updating-modal

    Add an example of updating modal
    parsley42 authored Feb 10, 2024
    Copy the full SHA
    398133c View commit details

Commits on Feb 11, 2024

  1. Copy the full SHA
    e1cc0bf View commit details

Commits on Feb 12, 2024

  1. Copy the full SHA
    a31aeaa View commit details
  2. Merge pull request #1261 from zFlabmonsta/master

    add deleted timestamp for deleted msg events
    parsley42 authored Feb 12, 2024
    Copy the full SHA
    c038c02 View commit details

Commits on Feb 14, 2024

  1. Copy the full SHA
    b6db972 View commit details

Commits on Feb 16, 2024

  1. Merge pull request #1262 from Birtato/addSlackConnectEvents

    Add slack connect events & tests
    parsley42 authored Feb 16, 2024
    Copy the full SHA
    5dbee1c View commit details
  2. Merge pull request #1260 from rusq/rich-text-stuff

    Add rich_text_quote and rich_text_preformatted
    parsley42 authored Feb 16, 2024
    Copy the full SHA
    2a9c35c View commit details
Showing with 1,503 additions and 129 deletions.
  1. +2 −0 block.go
  2. +18 −3 block_conv.go
  3. +74 −0 block_element.go
  4. +32 −0 block_element_test.go
  5. +146 −1 block_rich_text.go
  6. +247 −3 block_rich_text_test.go
  7. +65 −0 block_video.go
  8. +23 −0 block_video_test.go
  9. +4 −0 conversation.go
  10. +1 −1 examples/blocks/README.md
  11. +44 −10 examples/modal/modal.go
  12. +24 −23 interactions.go
  13. +44 −13 oauth.go
  14. +156 −39 slackevents/inner_events.go
  15. +592 −8 slackevents/inner_events_test.go
  16. +2 −2 slackevents/parsers.go
  17. +2 −2 slacktest/data.go
  18. +1 −1 slacktest/server_test.go
  19. +16 −14 slash.go
  20. +10 −9 users.go
2 changes: 2 additions & 0 deletions block.go
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ const (
MBTInput MessageBlockType = "input"
MBTHeader MessageBlockType = "header"
MBTRichText MessageBlockType = "rich_text"
MBTVideo MessageBlockType = "video"
)

// Block defines an interface all block types should implement
@@ -39,6 +40,7 @@ type BlockAction struct {
Type ActionType `json:"type"`
Text TextBlockObject `json:"text"`
Value string `json:"value"`
Files []File `json:"files"`
ActionTs string `json:"action_ts"`
SelectedOption OptionBlockObject `json:"selected_option"`
SelectedOptions []OptionBlockObject `json:"selected_options"`
21 changes: 18 additions & 3 deletions block_conv.go
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ package slack

import (
"encoding/json"
"errors"
"fmt"
)

@@ -66,8 +65,12 @@ func (b *Blocks) UnmarshalJSON(data []byte) error {
block = &InputBlock{}
case "rich_text":
block = &RichTextBlock{}
case "rich_text_input":
block = &RichTextBlock{}
case "section":
block = &SectionBlock{}
case "video":
block = &VideoBlock{}
default:
block = &UnknownBlock{}
}
@@ -114,6 +117,8 @@ func (b *InputBlock) UnmarshalJSON(data []byte) error {
e = &DateTimePickerBlockElement{}
case "plain_text_input":
e = &PlainTextInputBlockElement{}
case "rich_text_input":
e = &RichTextInputBlockElement{}
case "email_text_input":
e = &EmailTextInputBlockElement{}
case "url_text_input":
@@ -130,8 +135,10 @@ func (b *InputBlock) UnmarshalJSON(data []byte) error {
e = &RadioButtonsBlockElement{}
case "number_input":
e = &NumberInputBlockElement{}
case "file_input":
e = &FileInputBlockElement{}
default:
return errors.New("unsupported block element type")
return fmt.Errorf("unsupported block element type %v", s.TypeVal)
}

if err := json.Unmarshal(a.Element, e); err != nil {
@@ -196,6 +203,8 @@ func (b *BlockElements) UnmarshalJSON(data []byte) error {
blockElement = &DateTimePickerBlockElement{}
case "plain_text_input":
blockElement = &PlainTextInputBlockElement{}
case "rich_text_input":
blockElement = &RichTextInputBlockElement{}
case "email_text_input":
blockElement = &EmailTextInputBlockElement{}
case "url_text_input":
@@ -298,6 +307,12 @@ func (a *Accessory) UnmarshalJSON(data []byte) error {
return err
}
a.PlainTextInputElement = element.(*PlainTextInputBlockElement)
case "rich_text_input":
element, err := unmarshalBlockElement(r, &RichTextInputBlockElement{})
if err != nil {
return err
}
a.RichTextInputElement = element.(*RichTextInputBlockElement)
case "radio_buttons":
element, err := unmarshalBlockElement(r, &RadioButtonsBlockElement{})
if err != nil {
@@ -429,7 +444,7 @@ func (e *ContextElements) UnmarshalJSON(data []byte) error {

e.Elements = append(e.Elements, elem.(*ImageBlockElement))
default:
return errors.New("unsupported context element type")
return fmt.Errorf("unsupported context element type %v", contextElementType)
}
}

74 changes: 74 additions & 0 deletions block_element.go
Original file line number Diff line number Diff line change
@@ -12,9 +12,11 @@ const (
METDatetimepicker MessageElementType = "datetimepicker"
METPlainTextInput MessageElementType = "plain_text_input"
METRadioButtons MessageElementType = "radio_buttons"
METRichTextInput MessageElementType = "rich_text_input"
METEmailTextInput MessageElementType = "email_text_input"
METURLTextInput MessageElementType = "url_text_input"
METNumber MessageElementType = "number_input"
METFileInput MessageElementType = "file_input"

MixedElementImage MixedElementType = "mixed_image"
MixedElementText MixedElementType = "mixed_text"
@@ -51,6 +53,7 @@ type Accessory struct {
DatePickerElement *DatePickerBlockElement
TimePickerElement *TimePickerBlockElement
PlainTextInputElement *PlainTextInputBlockElement
RichTextInputElement *RichTextInputBlockElement
RadioButtonsElement *RadioButtonsBlockElement
SelectElement *SelectBlockElement
MultiSelectElement *MultiSelectBlockElement
@@ -73,6 +76,8 @@ func NewAccessory(element BlockElement) *Accessory {
return &Accessory{TimePickerElement: element.(*TimePickerBlockElement)}
case *PlainTextInputBlockElement:
return &Accessory{PlainTextInputElement: element.(*PlainTextInputBlockElement)}
case *RichTextInputBlockElement:
return &Accessory{RichTextInputElement: element.(*RichTextInputBlockElement)}
case *RadioButtonsBlockElement:
return &Accessory{RadioButtonsElement: element.(*RadioButtonsBlockElement)}
case *SelectBlockElement:
@@ -177,6 +182,12 @@ func (s *ButtonBlockElement) WithConfirm(confirm *ConfirmationBlockObject) *Butt
return s
}

// WithURL adds a URL for the button to link to and returns the modified ButtonBlockElement
func (s *ButtonBlockElement) WithURL(url string) *ButtonBlockElement {
s.URL = url
return s
}

// NewButtonBlockElement returns an instance of a new button element to be used within a block
func NewButtonBlockElement(actionID, value string, text *TextBlockObject) *ButtonBlockElement {
return &ButtonBlockElement{
@@ -509,6 +520,32 @@ func NewPlainTextInputBlockElement(placeholder *TextBlockObject, actionID string
}
}

// RichTextInputBlockElement creates a field where allows users to enter formatted text
// in a WYSIWYG composer, offering the same messaging writing experience as in Slack
// More Information: https://api.slack.com/reference/block-kit/block-elements#rich_text_input
type RichTextInputBlockElement struct {
Type MessageElementType `json:"type"`
ActionID string `json:"action_id,omitempty"`
Placeholder *TextBlockObject `json:"placeholder,omitempty"`
InitialValue string `json:"initial_value,omitempty"`
DispatchActionConfig *DispatchActionConfig `json:"dispatch_action_config,omitempty"`
FocusOnLoad bool `json:"focus_on_load,omitempty"`
}

// ElementType returns the type of the Element
func (s RichTextInputBlockElement) ElementType() MessageElementType {
return s.Type
}

// NewRichTextInputBlockElement returns an instance of a rich-text input element
func NewRichTextInputBlockElement(placeholder *TextBlockObject, actionID string) *RichTextInputBlockElement {
return &RichTextInputBlockElement{
Type: METRichTextInput,
ActionID: actionID,
Placeholder: placeholder,
}
}

// CheckboxGroupsBlockElement defines an element which allows users to choose
// one or more items from a list of possible options.
//
@@ -591,3 +628,40 @@ func NewNumberInputBlockElement(placeholder *TextBlockObject, actionID string, i
IsDecimalAllowed: isDecimalAllowed,
}
}

// FileInputBlockElement creates a field where a user can upload a file.
//
// File input elements are currently only available in modals.
//
// More Information: https://api.slack.com/reference/block-kit/block-elements#file_input
type FileInputBlockElement struct {
Type MessageElementType `json:"type"`
ActionID string `json:"action_id,omitempty"`
FileTypes []string `json:"filetypes,omitempty"`
MaxFiles int `json:"max_files,omitempty"`
}

// ElementType returns the type of the Element
func (s FileInputBlockElement) ElementType() MessageElementType {
return s.Type
}

// NewFileInputBlockElement returns an instance of a file input element
func NewFileInputBlockElement(actionID string) *FileInputBlockElement {
return &FileInputBlockElement{
Type: METFileInput,
ActionID: actionID,
}
}

// WithFileTypes sets the file types that can be uploaded
func (s *FileInputBlockElement) WithFileTypes(fileTypes ...string) *FileInputBlockElement {
s.FileTypes = fileTypes
return s
}

// WithMaxFiles sets the maximum number of files that can be uploaded
func (s *FileInputBlockElement) WithMaxFiles(maxFiles int) *FileInputBlockElement {
s.MaxFiles = maxFiles
return s
}
32 changes: 32 additions & 0 deletions block_element_test.go
Original file line number Diff line number Diff line change
@@ -43,6 +43,16 @@ func TestWithStyleForButtonElement(t *testing.T) {

}

func TestWithURLForButtonElement(t *testing.T) {

btnTxt := NewTextBlockObject("plain_text", "Next 2 Results", false, false)
btnElement := NewButtonBlockElement("test", "click_me_123", btnTxt)

btnElement.WithURL("https://foo.bar")
assert.Equal(t, btnElement.URL, "https://foo.bar")

}

func TestNewOptionsSelectBlockElement(t *testing.T) {

testOptionText := NewTextBlockObject("plain_text", "Option One", false, false)
@@ -148,6 +158,12 @@ func TestNewPlainTextInputBlockElement(t *testing.T) {

}

func TestNewRichTextInputBlockElement(t *testing.T) {
richTextInputElement := NewRichTextInputBlockElement(nil, "test")
assert.Equal(t, string(richTextInputElement.Type), "rich_text_input")
assert.Equal(t, richTextInputElement.ActionID, "test")
}

func TestNewEmailTextInputBlockElement(t *testing.T) {
emailTextInputElement := NewEmailTextInputBlockElement(nil, "example@example.com")

@@ -215,3 +231,19 @@ func TestNewNumberInputBlockElement(t *testing.T) {
assert.Equal(t, numberInputElement.IsDecimalAllowed, true)

}

func TestNewFileInputBlockElement(t *testing.T) {

fileInputElement := NewFileInputBlockElement("test")

assert.Equal(t, string(fileInputElement.Type), "file_input")
assert.Equal(t, fileInputElement.ActionID, "test")

fileInputElement.WithFileTypes("jpg", "png")
assert.Equal(t, len(fileInputElement.FileTypes), 2)
assert.Contains(t, fileInputElement.FileTypes, "jpg")
assert.Contains(t, fileInputElement.FileTypes, "png")

fileInputElement.WithMaxFiles(10)
assert.Equal(t, fileInputElement.MaxFiles, 10)
}
Loading