fix: null response obtaining messages from relay (#296)

This commit is contained in:
Richard Ramos 2022-09-08 08:54:12 -04:00 committed by GitHub
parent b226f34f9f
commit db85642862
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 7 deletions

View File

@ -145,7 +145,6 @@ func (d *RelayService) getV1Messages(w http.ResponseWriter, r *http.Request) {
}
var err error
var response []*pb.WakuMessage
d.messagesMutex.Lock()
defer d.messagesMutex.Unlock()
@ -155,14 +154,14 @@ func (d *RelayService) getV1Messages(w http.ResponseWriter, r *http.Request) {
_, err = w.Write([]byte("not subscribed to topic"))
d.log.Error("writing response", zap.Error(err))
return
} else {
}
response := make([]*pb.WakuMessage, len(d.messages[topic]))
for i := range d.messages[topic] {
response = append(response, d.messages[topic][i])
}
d.messages[topic] = make([]*pb.WakuMessage, 0)
}
writeErrOrResponse(w, err, response)
writeErrOrResponse(w, nil, response)
}
func (d *RelayService) postV1Message(w http.ResponseWriter, r *http.Request) {