mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-20 14:35:07 +00:00
fix notes v2
This commit is contained in:
@@ -2,6 +2,7 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -28,8 +29,10 @@ type Notes struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newMessage(ev map[string]interface{}) *structpb.Struct {
|
func newMessage(ev map[string]interface{}) *structpb.Struct {
|
||||||
v, _ := structpb.NewStruct(ev)
|
st := new(structpb.Struct)
|
||||||
return v
|
b, _ := json.Marshal(ev)
|
||||||
|
json.Unmarshal(b, st)
|
||||||
|
return st
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create inserts a new note in the store
|
// Create inserts a new note in the store
|
||||||
@@ -190,7 +193,14 @@ func (h *Notes) Subscribe(ctx context.Context, req *pb.SubscribeRequest, stream
|
|||||||
}
|
}
|
||||||
|
|
||||||
ev := msg.Message.AsMap()
|
ev := msg.Message.AsMap()
|
||||||
note := ev["note"].(*pb.Note)
|
if ev == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
note, ok := ev["note"].(*pb.Note)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// 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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user