Fix unmarshall error with Invite, improve error logging.
This commit is contained in:
parent
24e7f04e0e
commit
8be21fb539
3 changed files with 9 additions and 8 deletions
|
@ -1111,7 +1111,7 @@ func (s *Session) ChannelInviteCreate(channelID string, i Invite) (st *Invite, e
|
||||||
MaxAge int `json:"max_age"`
|
MaxAge int `json:"max_age"`
|
||||||
MaxUses int `json:"max_uses"`
|
MaxUses int `json:"max_uses"`
|
||||||
Temporary bool `json:"temporary"`
|
Temporary bool `json:"temporary"`
|
||||||
XKCDPass bool `json:"xkcdpass"`
|
XKCDPass string `json:"xkcdpass"`
|
||||||
}{i.MaxAge, i.MaxUses, i.Temporary, i.XkcdPass}
|
}{i.MaxAge, i.MaxUses, i.Temporary, i.XkcdPass}
|
||||||
|
|
||||||
body, err := s.Request("POST", CHANNEL_INVITES(channelID), data)
|
body, err := s.Request("POST", CHANNEL_INVITES(channelID), data)
|
||||||
|
|
|
@ -107,7 +107,7 @@ type Invite struct {
|
||||||
MaxAge int `json:"max_age"`
|
MaxAge int `json:"max_age"`
|
||||||
Uses int `json:"uses"`
|
Uses int `json:"uses"`
|
||||||
MaxUses int `json:"max_uses"`
|
MaxUses int `json:"max_uses"`
|
||||||
XkcdPass bool `json:"xkcdpass"`
|
XkcdPass string `json:"xkcdpass"`
|
||||||
Revoked bool `json:"revoked"`
|
Revoked bool `json:"revoked"`
|
||||||
Temporary bool `json:"temporary"`
|
Temporary bool `json:"temporary"`
|
||||||
}
|
}
|
||||||
|
|
7
wsapi.go
7
wsapi.go
|
@ -15,6 +15,7 @@ import (
|
||||||
"compress/zlib"
|
"compress/zlib"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -256,7 +257,7 @@ func (s *Session) event(messageType int, message []byte) {
|
||||||
if messageType == 2 {
|
if messageType == 2 {
|
||||||
z, err1 := zlib.NewReader(reader)
|
z, err1 := zlib.NewReader(reader)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
log.Println(err1)
|
log.Println(fmt.Sprintf("Error uncompressing message type %d: %s", messageType, err1))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -271,7 +272,7 @@ func (s *Session) event(messageType int, message []byte) {
|
||||||
var e *Event
|
var e *Event
|
||||||
decoder := json.NewDecoder(reader)
|
decoder := json.NewDecoder(reader)
|
||||||
if err = decoder.Decode(&e); err != nil {
|
if err = decoder.Decode(&e); err != nil {
|
||||||
log.Println(err)
|
log.Println(fmt.Sprintf("Error decoding message type %d: %s", messageType, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,7 +288,7 @@ func (s *Session) event(messageType int, message []byte) {
|
||||||
// Attempt to unmarshal our event.
|
// Attempt to unmarshal our event.
|
||||||
// If there is an error we should handle the event itself.
|
// If there is an error we should handle the event itself.
|
||||||
if err = unmarshal(e.RawData, i); err != nil {
|
if err = unmarshal(e.RawData, i); err != nil {
|
||||||
log.Println("Unable to unmarshal event data.", err)
|
log.Println(fmt.Sprintf("Unable to unmarshal event %s data: %s", e.Type, err))
|
||||||
// Ready events must fire, even if they are empty.
|
// Ready events must fire, even if they are empty.
|
||||||
if e.Type != "READY" {
|
if e.Type != "READY" {
|
||||||
i = nil
|
i = nil
|
||||||
|
|
Loading…
Reference in a new issue