Skip to content
Snippets Groups Projects
Unverified Commit 25a5456c authored by Acha Bill's avatar Acha Bill Committed by GitHub
Browse files

add empty Message in result if not exists (#512)

parent 85eceeb7
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment