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 string `json:"type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChatEventDataFix struct {
|
type ChatEventDataNoChannels struct {
|
||||||
Channels [][]string `json:"channels"`
|
Channels [][]string `json:"channels"`
|
||||||
Messages []ChatEventMessage `json:"messages"`
|
Messages []ChatEventMessage `json:"messages"`
|
||||||
Users []ChatEventUser `json:"users"`
|
Users []ChatEventUser `json:"users"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChatEventFix struct {
|
type ChatEventNoChannels struct {
|
||||||
Data ChatEventDataFix `json:"data"`
|
Data ChatEventDataNoChannels `json:"data"`
|
||||||
RequestID string `json:"request_id"`
|
RequestID string `json:"request_id"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
|
@ -317,14 +317,14 @@ func parseEvent(event []byte) ([]ChatView, error) {
|
||||||
var ce ChatEvent
|
var ce ChatEvent
|
||||||
err := json.Unmarshal(event, &ce)
|
err := json.Unmarshal(event, &ce)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var cef ChatEventFix
|
var cenc ChatEventNoChannels
|
||||||
errFix := json.Unmarshal(event, &cef)
|
errNC := json.Unmarshal(event, &cenc)
|
||||||
if errFix != nil {
|
if errNC != nil {
|
||||||
return nil, fmt.Errorf("error un-marshaling event: %v", err)
|
return nil, fmt.Errorf("error un-marshaling event: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ce.Data.Messages = cef.Data.Messages
|
ce.Data.Messages = cenc.Data.Messages
|
||||||
ce.Data.Users = cef.Data.Users
|
ce.Data.Users = cenc.Data.Users
|
||||||
}
|
}
|
||||||
|
|
||||||
users := chatUsers(ce.Data.Users)
|
users := chatUsers(ce.Data.Users)
|
||||||
|
|
Loading…
Reference in a new issue