Skip to content

Commit

Permalink
Merge pull request #1122 from yokishava/fix/replace-original-omitemtpy
Browse files Browse the repository at this point in the history
fix: remove omitempty from replace_original and delete_orginal
  • Loading branch information
kanata2 authored Nov 4, 2022
2 parents df7caaf + e745a45 commit c99b47b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ type WebhookMessage struct {
Parse string `json:"parse,omitempty"`
Blocks *Blocks `json:"blocks,omitempty"`
ResponseType string `json:"response_type,omitempty"`
ReplaceOriginal bool `json:"replace_original,omitempty"`
DeleteOriginal bool `json:"delete_original,omitempty"`
ReplaceOriginal bool `json:"replace_original"`
DeleteOriginal bool `json:"delete_original"`
ReplyBroadcast bool `json:"reply_broadcast,omitempty"`
}

Expand Down
6 changes: 3 additions & 3 deletions webhooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ func TestWebhookMessage_WithBlocks(t *testing.T) {
assert.Equal(t, 1, len(msgSingleBlock.Blocks.BlockSet))

msgJsonSingleBlock, _ := json.Marshal(msgSingleBlock)
assert.Equal(t, `{"blocks":[{"type":"section","text":{"type":"plain_text","text":"text"}}]}`, string(msgJsonSingleBlock))
assert.Equal(t, `{"blocks":[{"type":"section","text":{"type":"plain_text","text":"text"}}],"replace_original":false,"delete_original":false}`, string(msgJsonSingleBlock))

msgTwoBlocks := WebhookMessage{Blocks: twoBlocks}
assert.Equal(t, 2, len(msgTwoBlocks.Blocks.BlockSet))

msgJsonTwoBlocks, _ := json.Marshal(msgTwoBlocks)
assert.Equal(t, `{"blocks":[{"type":"section","text":{"type":"plain_text","text":"text"}},{"type":"section","text":{"type":"plain_text","text":"text"}}]}`, string(msgJsonTwoBlocks))
assert.Equal(t, `{"blocks":[{"type":"section","text":{"type":"plain_text","text":"text"}},{"type":"section","text":{"type":"plain_text","text":"text"}}],"replace_original":false,"delete_original":false}`, string(msgJsonTwoBlocks))

msgNoBlocks := WebhookMessage{Text: "foo"}
msgJsonNoBlocks, _ := json.Marshal(msgNoBlocks)
assert.Equal(t, `{"text":"foo"}`, string(msgJsonNoBlocks))
assert.Equal(t, `{"text":"foo","replace_original":false,"delete_original":false}`, string(msgJsonNoBlocks))
}

0 comments on commit c99b47b

Please sign in to comment.