From 3002812c021427a6285a46b1d14d299e5aedf767 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Mon, 20 Nov 2017 09:58:20 +0900 Subject: [PATCH 1/2] fix #66 --- streaming.go | 2 +- streaming_ws.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/streaming.go b/streaming.go index 4689ece..b3242a4 100644 --- a/streaming.go +++ b/streaming.go @@ -69,7 +69,7 @@ func handleReader(q chan Event, r io.Reader) error { q <- &NotificationEvent{¬ification} } case "delete": - q <- &DeleteEvent{ID(strings.TrimSpace(token[1]))} + q <- &DeleteEvent{ID: ID(strings.TrimSpace(token[1]))} } if err != nil { q <- &ErrorEvent{err} diff --git a/streaming_ws.go b/streaming_ws.go index 80e357b..d027f89 100644 --- a/streaming_ws.go +++ b/streaming_ws.go @@ -3,9 +3,9 @@ package mastodon import ( "context" "encoding/json" - "fmt" "net/url" "path" + "strings" "github.com/gorilla/websocket" ) @@ -128,7 +128,7 @@ func (c *WSClient) handleWS(ctx context.Context, rawurl string, q chan Event) er q <- &NotificationEvent{Notification: ¬ification} } case "delete": - q <- &DeleteEvent{ID: ID(fmt.Sprint(int64(s.Payload.(float64))))} + q <- &DeleteEvent{ID: ID(strings.TrimSpace(s.Payload.(string)))} } if err != nil { q <- &ErrorEvent{err} From 81259792b723e0ca85222dd294949fd2b2e9d9fb Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Mon, 20 Nov 2017 10:04:53 +0900 Subject: [PATCH 2/2] handle float64/string both --- streaming_ws.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/streaming_ws.go b/streaming_ws.go index d027f89..d37fcfe 100644 --- a/streaming_ws.go +++ b/streaming_ws.go @@ -3,6 +3,7 @@ package mastodon import ( "context" "encoding/json" + "fmt" "net/url" "path" "strings" @@ -128,7 +129,11 @@ func (c *WSClient) handleWS(ctx context.Context, rawurl string, q chan Event) er q <- &NotificationEvent{Notification: ¬ification} } case "delete": - q <- &DeleteEvent{ID: ID(strings.TrimSpace(s.Payload.(string)))} + 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}