mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-19 22:15:24 +00:00
fix notes v3
This commit is contained in:
@@ -192,26 +192,26 @@ func (h *Notes) Subscribe(ctx context.Context, req *pb.SubscribeRequest, stream
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
ev := msg.Message.AsMap()
|
v, err := msg.Message.MarshalJSON()
|
||||||
if ev == nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
note, ok := ev["note"].(*pb.Note)
|
rsp := new(pb.SubscribeResponse)
|
||||||
if !ok {
|
|
||||||
|
if err := json.Unmarshal(v, rsp); err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
note := rsp.Note
|
||||||
|
|
||||||
// filter if necessary by id
|
// filter if necessary by id
|
||||||
if len(req.Id) > 0 && note.Id != req.Id {
|
if len(req.Id) > 0 && note.Id != req.Id {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// send back the event to the client
|
// send back the event to the client
|
||||||
if err := stream.Send(&pb.SubscribeResponse{
|
if err := stream.Send(rsp); err != nil {
|
||||||
Event: ev["type"].(string),
|
|
||||||
Note: note,
|
|
||||||
}); err != nil {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user