Discovery Nats Related

This commit is contained in:
mr
2026-01-28 17:23:55 +01:00
parent a9e737fb4f
commit e650ad479d
15 changed files with 221 additions and 1197 deletions

View File

@@ -1,10 +1,12 @@
package controllers
import (
"encoding/json"
"fmt"
"oc-catalog/infrastructure"
oclib "cloud.o-forge.io/core/oc-lib"
"cloud.o-forge.io/core/oc-lib/tools"
beego "github.com/beego/beego/v2/server/web"
)
@@ -95,7 +97,16 @@ func (o *ResourceController) SearchDecentralized() {
user, _, _ := oclib.ExtractTokenInfo(*o.Ctx.Request)
search := o.Ctx.Input.Param(":search")
t := o.Ctx.Input.Param(":type")
err := infrastructure.Singleton.SearchPublishEvent(o.Ctx.Request.Context(), nil, t, user, search)
b, err := json.Marshal(map[string]string{
"search": search,
"type": t,
})
infrastructure.EmitNATS(tools.PropalgationMessage{
Action: tools.PB_SEARCH,
DataType: -1,
User: user,
Payload: b,
})
if err != nil {
o.Data["json"] = map[string]interface{}{
"data": nil,