From 82cc8e08026a8ec789d060475f0b27182e5c2f96 Mon Sep 17 00:00:00 2001 From: Michael Stewart Date: Mon, 27 Jul 2015 15:50:43 -0400 Subject: [PATCH] Fixed unmarshalling for channel rename event. --- websocket_channels.go | 11 ++++++----- websocket_groups.go | 13 ++++++++++++- websocket_managed_conn.go | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/websocket_channels.go b/websocket_channels.go index 39ae4a4b7..fed106132 100644 --- a/websocket_channels.go +++ b/websocket_channels.go @@ -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 diff --git a/websocket_groups.go b/websocket_groups.go index c5ec6bad7..eb88985c4 100644 --- a/websocket_groups.go +++ b/websocket_groups.go @@ -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 diff --git a/websocket_managed_conn.go b/websocket_managed_conn.go index 061dc297f..5a780c684 100644 --- a/websocket_managed_conn.go +++ b/websocket_managed_conn.go @@ -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