From 77a2c22a66a16d48f4619c950057cffe781c12b8 Mon Sep 17 00:00:00 2001 From: capossele <angelocapossele@gmail.com> Date: Thu, 2 Apr 2020 20:15:38 +0100 Subject: [PATCH] :sparkles: makes boradcastData generic --- plugins/webapi/broadcastData/plugin.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/webapi/broadcastData/plugin.go b/plugins/webapi/broadcastData/plugin.go index b67903fb..f4b94ef8 100644 --- a/plugins/webapi/broadcastData/plugin.go +++ b/plugins/webapi/broadcastData/plugin.go @@ -7,6 +7,7 @@ import ( "github.com/iotaledger/goshimmer/plugins/messagelayer" "github.com/iotaledger/goshimmer/plugins/webapi" "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/marshalutil" "github.com/iotaledger/hive.go/node" "github.com/labstack/echo" ) @@ -30,7 +31,12 @@ func broadcastData(c echo.Context) error { //TODO: to check max payload size allowed, if exceeding return an error - tx := messagelayer.MessageFactory.IssuePayload(payload.NewData(request.Data)) + marshalUtil := marshalutil.New(request.Data) + parsedPayload, err := payload.Parse(marshalUtil) + if err != nil { + return c.JSON(http.StatusBadRequest, Response{Error: "Not a valid Payload"}) + } + tx := messagelayer.MessageFactory.IssuePayload(parsedPayload) return c.JSON(http.StatusOK, Response{Id: tx.Id().String()}) } -- GitLab