handle float64/string both

fix-66
Yasuhiro Matsumoto 2017-11-20 10:04:53 +09:00
parent 3002812c02
commit 81259792b7
1 changed files with 6 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package mastodon
import (
"context"
"encoding/json"
"fmt"
"net/url"
"path"
"strings"
@ -128,8 +129,12 @@ func (c *WSClient) handleWS(ctx context.Context, rawurl string, q chan Event) er
q <- &NotificationEvent{Notification: &notification}
}
case "delete":
if f, ok := s.Payload.(float64); ok {
q <- &DeleteEvent{ID: ID(fmt.Sprint(int64(f)))}
} else {
q <- &DeleteEvent{ID: ID(strings.TrimSpace(s.Payload.(string)))}
}
}
if err != nil {
q <- &ErrorEvent{err}
}