diff --git a/plugins/webapi/message/plugin.go b/plugins/webapi/message/plugin.go index bdba4f3740deaf17d000969693b531de05c9cd5e..7e29b872a354005704691d82c221df31bc6988a9 100644 --- a/plugins/webapi/message/plugin.go +++ b/plugins/webapi/message/plugin.go @@ -30,6 +30,7 @@ func configure(plugin *node.Plugin) { // given message ids (MUST be encoded in base58), in the same order as the parameters. // If a node doesn't have the message for a given ID in its ledger, // the value at the index of that message ID is empty. +// If an ID is not base58 encoded, an error is returned func findMessageByID(c echo.Context) error { var request Request if err := c.Bind(&request); err != nil { @@ -44,15 +45,14 @@ func findMessageByID(c echo.Context) error { msgID, err := message.NewId(id) if err != nil { log.Info(err) - continue + return c.JSON(http.StatusBadRequest, Response{Error: err.Error()}) } msgObject := messagelayer.Tangle.Message(msgID) - if !msgObject.Exists() { - continue - } msgMetadataObject := messagelayer.Tangle.MessageMetadata(msgID) - if !msgMetadataObject.Exists() { + + if !msgObject.Exists() || !msgMetadataObject.Exists() { + result = append(result, Message{}) continue }