Skip to content

Commit

Permalink
Add silent flag to messages (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhatelmas authored Sep 18, 2020
1 parent 213da83 commit 18991a6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,18 @@ func TestChannel_SendMessage(t *testing.T) {
// check that message was updated
assert.NotEmpty(t, msg.ID, "message has ID")
assert.NotEmpty(t, msg.HTML, "message has HTML body")

msg2 := &Message{
Text: "text message 2",
User: user,
Silent: true,
}
msg2, err = ch.SendMessage(msg2, serverUser.ID)
require.NoError(t, err, "send message 2")
// check that message was updated
assert.NotEmpty(t, msg2.ID, "message has ID")
assert.NotEmpty(t, msg2.HTML, "message has HTML body")
assert.True(t, msg2.Silent, "message silent flag is set")
}

func TestChannel_Truncate(t *testing.T) {
Expand Down
5 changes: 4 additions & 1 deletion message.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ type Message struct {
Text string `json:"text"`
HTML string `json:"html"`

Type MessageType `json:"type,omitempty"` // one of MessageType* constants
Type MessageType `json:"type,omitempty"` // one of MessageType* constants
Silent bool `json:"silent,omitempty"`

User *User `json:"user"`
Attachments []*Attachment `json:"attachments"`
Expand Down Expand Up @@ -78,6 +79,7 @@ func (m *Message) toRequest() messageRequest {
ExtraData: m.ExtraData,
ParentID: m.ParentID,
ShowInChannel: m.ShowInChannel,
Silent: m.Silent,
}

if len(m.MentionedUsers) > 0 {
Expand All @@ -101,6 +103,7 @@ type messageRequestMessage struct {
MentionedUsers []string `json:"mentioned_users"`
ParentID string `json:"parent_id"`
ShowInChannel bool `json:"show_in_channel"`
Silent bool `json:"silent"`

ExtraData map[string]interface{} `json:"-"`
}
Expand Down

0 comments on commit 18991a6

Please sign in to comment.