Codebase list golang-github-nlopes-slack / 82cc8e0
Fixed unmarshalling for channel rename event. Michael Stewart authored 8 years ago Norberto Lopes committed 8 years ago
3 changed file(s) with 19 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
3535
3636 // ChannelRenameEvent represents the Channel rename event
3737 type ChannelRenameEvent struct {
38 Type string `json:"type"`
39 Channel ChannelRenameInfo `json:"channel"`
38 Type string `json:"type"`
39 Channel ChannelRenameInfo `json:"channel"`
40 Timestamp string `json:"event_ts"`
4041 }
4142
4243 // ChannelRenameInfo represents the information associated with a Channel rename event
4344 type ChannelRenameInfo struct {
44 ID string `json:"id"`
45 Name string `json:"name"`
46 Created JSONTimeString `json:"created"`
45 ID string `json:"id"`
46 Name string `json:"name"`
47 Created *JSONTimeString `json:"created"`
4748 }
4849
4950 // ChannelHistoryChangedEvent represents the Channel history changed event
3131 type GroupJoinedEvent ChannelJoinedEvent
3232
3333 // GroupRenameEvent represents the Group rename event
34 type GroupRenameEvent ChannelRenameEvent
34 type GroupRenameEvent struct {
35 Type string `json:"type"`
36 Group GroupRenameInfo `json:"channel"`
37 Timestamp string `json:"ts"`
38 }
39
40 // GroupRenameInfo represents the group info related to the renamed group
41 type GroupRenameInfo struct {
42 ID string `json:"id"`
43 Name string `json:"name"`
44 Created string `json:"created"`
45 }
3546
3647 // GroupHistoryChangedEvent represents the Group history changed event
3748 type GroupHistoryChangedEvent ChannelHistoryChangedEvent
388388 recvEvent := reflect.New(t).Interface()
389389 err := json.Unmarshal(event, recvEvent)
390390 if err != nil {
391 rtm.Debugf("RTM Error, received unmapped event %q: %s\n", typeStr, string(event))
391 rtm.Debugf("RTM Error, could not unmarshall event %q: %s\n", typeStr, string(event))
392392 err := fmt.Errorf("RTM Error: Could not unmarshall event %q: %s\n", typeStr, string(event))
393393 rtm.IncomingEvents <- SlackEvent{"unmarshalling_error", &UnmarshallingErrorEvent{err}}
394394 return