No Blacklisted + Hoping and diffused research

This commit is contained in:
mr
2026-02-02 12:14:01 +01:00
parent c3352499fa
commit 0ffe98045e
6 changed files with 57 additions and 18 deletions

46
daemons/node/nats.go Normal file
View File

@@ -0,0 +1,46 @@
package node
import (
"context"
"encoding/json"
"fmt"
"cloud.o-forge.io/core/oc-lib/tools"
)
func ListenNATS(n Node) {
tools.NewNATSCaller().ListenNats(map[tools.NATSMethod]func(tools.NATSResponse){
tools.PROPALGATION_EVENT: func(resp tools.NATSResponse) {
var propalgation tools.PropalgationMessage
err := json.Unmarshal(resp.Payload, &propalgation)
var dt *tools.DataType
if propalgation.DataType > 0 {
dtt := tools.DataType(propalgation.DataType)
dt = &dtt
}
if err == nil {
switch propalgation.Action {
case tools.PB_CREATE:
case tools.PB_UPDATE:
case tools.PB_DELETE:
n.StreamService.ToPartnerPublishEvent(
context.Background(),
propalgation.Action,
dt, resp.User,
propalgation.Payload,
)
case tools.PB_SEARCH:
m := map[string]interface{}{}
json.Unmarshal(propalgation.Payload, &m)
n.PubSubService.SearchPublishEvent(
context.Background(),
dt,
fmt.Sprintf("%v", m["type"]),
resp.User,
fmt.Sprintf("%v", m["search"]),
)
}
}
},
})
}