Skip to content

Commit

Permalink
fix: change type of timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
yokishava committed Nov 22, 2022
1 parent c99b47b commit 43f721e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
6 changes: 3 additions & 3 deletions block_rich_text.go
Expand Up @@ -327,17 +327,17 @@ func NewRichTextSectionUserGroupElement(usergroupID string) *RichTextSectionUser

type RichTextSectionDateElement struct {
Type RichTextSectionElementType `json:"type"`
Timestamp string `json:"timestamp"`
Timestamp JSONTime `json:"timestamp"`
}

func (r RichTextSectionDateElement) RichTextSectionElementType() RichTextSectionElementType {
return r.Type
}

func NewRichTextSectionDateElement(timestamp string) *RichTextSectionDateElement {
func NewRichTextSectionDateElement(timestamp int64) *RichTextSectionDateElement {
return &RichTextSectionDateElement{
Type: RTSEDate,
Timestamp: timestamp,
Timestamp: JSONTime(timestamp),
}
}

Expand Down
25 changes: 2 additions & 23 deletions block_rich_text_test.go
Expand Up @@ -7,28 +7,6 @@ import (
"github.com/go-test/deep"
)

const (
dummyPayload = `{
"type":"rich_text",
"block_id":"FaYCD",
"elements": [
{
"type":"rich_text_section",
"elements": [
{
"type":"channel",
"channel_id":"C012345678"
},
{
"type":"text",
"text":"dummy_text"
}
]
}
]
}`
)

func TestRichTextBlock_UnmarshalJSON(t *testing.T) {
cases := []struct {
raw []byte
Expand Down Expand Up @@ -80,12 +58,13 @@ func TestRichTextSection_UnmarshalJSON(t *testing.T) {
err error
}{
{
[]byte(`{"elements":[{"type":"unknown","value":10},{"type":"text","text":"hi"}]}`),
[]byte(`{"elements":[{"type":"unknown","value":10},{"type":"text","text":"hi"},{"type":"date","timestamp":1636961629}]}`),
RichTextSection{
Type: RTESection,
Elements: []RichTextSectionElement{
&RichTextSectionUnknownElement{Type: RTSEUnknown, Raw: `{"type":"unknown","value":10}`},
&RichTextSectionTextElement{Type: RTSEText, Text: "hi"},
&RichTextSectionDateElement{Type: RTSEDate, Timestamp: JSONTime(1636961629)},
},
},
nil,
Expand Down

0 comments on commit 43f721e

Please sign in to comment.