mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
do some manual casting for script.js payload
This commit is contained in:
@@ -20,6 +20,18 @@ type ScriptJS struct {
|
|||||||
|
|
||||||
func (sj *ScriptJS) Process(ctx context.Context, payload any) (any, error) {
|
func (sj *ScriptJS) Process(ctx context.Context, payload any) (any, error) {
|
||||||
|
|
||||||
|
//NOTE(jwetzell): some weird conversion going on with these types
|
||||||
|
_, isUint8Slice := common.GetAnyAs[[]uint8](payload)
|
||||||
|
_, isbyteSlice := common.GetAnyAs[[]byte](payload)
|
||||||
|
|
||||||
|
if isUint8Slice || isbyteSlice {
|
||||||
|
intSlice, ok := common.GetAnyAsIntSlice(payload)
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
payload = intSlice
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sj.vm.SetProperty(sj.vm.GlobalObject(), sj.payloadAtom, payload)
|
sj.vm.SetProperty(sj.vm.GlobalObject(), sj.payloadAtom, payload)
|
||||||
|
|
||||||
sender := ctx.Value(common.SenderContextKey)
|
sender := ctx.Value(common.SenderContextKey)
|
||||||
@@ -49,6 +61,7 @@ func (sj *ScriptJS) Process(ctx context.Context, payload any) (any, error) {
|
|||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
var outputMap map[string]interface{}
|
var outputMap map[string]interface{}
|
||||||
|
fmt.Println(outputObject.String())
|
||||||
err := json.Unmarshal([]byte(outputObject.String()), &outputMap)
|
err := json.Unmarshal([]byte(outputObject.String()), &outputMap)
|
||||||
return outputMap, err
|
return outputMap, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user