Changed struct name to be clearer
This commit is contained in:
parent
3cb463e99a
commit
9e821689cf
16
chat.go
16
chat.go
|
@ -232,14 +232,14 @@ type ChatEvent struct {
|
|||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type ChatEventDataFix struct {
|
||||
type ChatEventDataNoChannels struct {
|
||||
Channels [][]string `json:"channels"`
|
||||
Messages []ChatEventMessage `json:"messages"`
|
||||
Users []ChatEventUser `json:"users"`
|
||||
}
|
||||
|
||||
type ChatEventFix struct {
|
||||
Data ChatEventDataFix `json:"data"`
|
||||
type ChatEventNoChannels struct {
|
||||
Data ChatEventDataNoChannels `json:"data"`
|
||||
RequestID string `json:"request_id"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
@ -317,14 +317,14 @@ func parseEvent(event []byte) ([]ChatView, error) {
|
|||
var ce ChatEvent
|
||||
err := json.Unmarshal(event, &ce)
|
||||
if err != nil {
|
||||
var cef ChatEventFix
|
||||
errFix := json.Unmarshal(event, &cef)
|
||||
if errFix != nil {
|
||||
var cenc ChatEventNoChannels
|
||||
errNC := json.Unmarshal(event, &cenc)
|
||||
if errNC != nil {
|
||||
return nil, fmt.Errorf("error un-marshaling event: %v", err)
|
||||
}
|
||||
|
||||
ce.Data.Messages = cef.Data.Messages
|
||||
ce.Data.Users = cef.Data.Users
|
||||
ce.Data.Messages = cenc.Data.Messages
|
||||
ce.Data.Users = cenc.Data.Users
|
||||
}
|
||||
|
||||
users := chatUsers(ce.Data.Users)
|
||||
|
|
Loading…
Reference in a new issue