mirror of https://github.com/status-im/go-waku.git
fix: null response obtaining messages from relay (#296)
This commit is contained in:
parent
b226f34f9f
commit
db85642862
|
@ -145,7 +145,6 @@ func (d *RelayService) getV1Messages(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
var response []*pb.WakuMessage
|
|
||||||
|
|
||||||
d.messagesMutex.Lock()
|
d.messagesMutex.Lock()
|
||||||
defer d.messagesMutex.Unlock()
|
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"))
|
_, err = w.Write([]byte("not subscribed to topic"))
|
||||||
d.log.Error("writing response", zap.Error(err))
|
d.log.Error("writing response", zap.Error(err))
|
||||||
return
|
return
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
response := make([]*pb.WakuMessage, len(d.messages[topic]))
|
||||||
for i := range d.messages[topic] {
|
for i := range d.messages[topic] {
|
||||||
response = append(response, d.messages[topic][i])
|
response = append(response, d.messages[topic][i])
|
||||||
}
|
}
|
||||||
d.messages[topic] = make([]*pb.WakuMessage, 0)
|
d.messages[topic] = make([]*pb.WakuMessage, 0)
|
||||||
}
|
writeErrOrResponse(w, nil, response)
|
||||||
|
|
||||||
writeErrOrResponse(w, err, response)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RelayService) postV1Message(w http.ResponseWriter, r *http.Request) {
|
func (d *RelayService) postV1Message(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
Loading…
Reference in New Issue