display status/reblog in stream

This commit is contained in:
Yasuhiro Matsumoto 2017-04-19 23:21:19 +09:00
parent f40839b98d
commit eb1c1cf0ae
4 changed files with 71 additions and 41 deletions

View file

@ -20,7 +20,9 @@ type UpdateEvent struct {
func (e *UpdateEvent) event() {}
// NotificationEvent is struct for passing notification event to app.
type NotificationEvent struct{}
type NotificationEvent struct {
Notification *Notification `json:"notification"`
}
func (e *NotificationEvent) event() {}
@ -61,7 +63,17 @@ func handleReader(ctx context.Context, q chan Event, r io.Reader) error {
q <- &UpdateEvent{&status}
}
case "notification":
var notification Notification
err := json.Unmarshal([]byte(token[1]), &notification)
if err == nil {
q <- &NotificationEvent{&notification}
}
case "delete":
var id int64
err := json.Unmarshal([]byte(token[1]), &id)
if err == nil {
q <- &DeleteEvent{id}
}
}
default:
}