Skip to content

Commit

Permalink
Fixed unmarshalling for channel rename event.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Stewart authored and nlopes committed Aug 16, 2015
1 parent 24224d9 commit 82cc8e0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
11 changes: 6 additions & 5 deletions websocket_channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ type ChannelInfoEvent struct {

// ChannelRenameEvent represents the Channel rename event
type ChannelRenameEvent struct {
Type string `json:"type"`
Channel ChannelRenameInfo `json:"channel"`
Type string `json:"type"`
Channel ChannelRenameInfo `json:"channel"`
Timestamp string `json:"event_ts"`
}

// ChannelRenameInfo represents the information associated with a Channel rename event
type ChannelRenameInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Created JSONTimeString `json:"created"`
ID string `json:"id"`
Name string `json:"name"`
Created *JSONTimeString `json:"created"`
}

// ChannelHistoryChangedEvent represents the Channel history changed event
Expand Down
13 changes: 12 additions & 1 deletion websocket_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@ type GroupLeftEvent ChannelInfoEvent
type GroupJoinedEvent ChannelJoinedEvent

// GroupRenameEvent represents the Group rename event
type GroupRenameEvent ChannelRenameEvent
type GroupRenameEvent struct {
Type string `json:"type"`
Group GroupRenameInfo `json:"channel"`
Timestamp string `json:"ts"`
}

// GroupRenameInfo represents the group info related to the renamed group
type GroupRenameInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Created string `json:"created"`
}

// GroupHistoryChangedEvent represents the Group history changed event
type GroupHistoryChangedEvent ChannelHistoryChangedEvent
2 changes: 1 addition & 1 deletion websocket_managed_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ func (rtm *RTM) handleEvent(typeStr string, event json.RawMessage) {
recvEvent := reflect.New(t).Interface()
err := json.Unmarshal(event, recvEvent)
if err != nil {
rtm.Debugf("RTM Error, received unmapped event %q: %s\n", typeStr, string(event))
rtm.Debugf("RTM Error, could not unmarshall event %q: %s\n", typeStr, string(event))
err := fmt.Errorf("RTM Error: Could not unmarshall event %q: %s\n", typeStr, string(event))
rtm.IncomingEvents <- SlackEvent{"unmarshalling_error", &UnmarshallingErrorEvent{err}}
return
Expand Down

0 comments on commit 82cc8e0

Please sign in to comment.