display status/reblog in stream
This commit is contained in:
parent
f40839b98d
commit
eb1c1cf0ae
4 changed files with 71 additions and 41 deletions
14
streaming.go
14
streaming.go
|
@ -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]), ¬ification)
|
||||
if err == nil {
|
||||
q <- &NotificationEvent{¬ification}
|
||||
}
|
||||
case "delete":
|
||||
var id int64
|
||||
err := json.Unmarshal([]byte(token[1]), &id)
|
||||
if err == nil {
|
||||
q <- &DeleteEvent{id}
|
||||
}
|
||||
}
|
||||
default:
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue