Skip to content

Commit

Permalink
nit: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-98 committed Oct 19, 2023
1 parent 9a55414 commit c9a339b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 6 additions & 4 deletions cmd/waku/server/rest/lightpush_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net/http"

"github.com/go-chi/chi/v5"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/waku-org/go-waku/waku/v2/node"
"github.com/waku-org/go-waku/waku/v2/protocol/lightpush"
"github.com/waku-org/go-waku/waku/v2/protocol/pb"
Expand All @@ -18,7 +17,6 @@ const routeLightPushV1Messages = "/lightpush/v1/message"
type LightpushService struct {
node *node.WakuNode
log *zap.Logger
id peer.ID
}

func NewLightpushService(node *node.WakuNode, m *chi.Mux, log *zap.Logger) *LightpushService {
Expand Down Expand Up @@ -53,14 +51,18 @@ func (serv *LightpushService) postMessagev1(w http.ResponseWriter, req *http.Req
return
}
defer req.Body.Close()

if err := msg.Check(); err != nil {
writeErrOrResponse(w, err, http.StatusBadRequest)
return
}
//

if serv.node.Lightpush() == nil {
w.WriteHeader(http.StatusServiceUnavailable)
return
}

serv.log.Info("", zap.String("", serv.id.String()))
_, err := serv.node.Lightpush().Publish(req.Context(), msg.Message, lightpush.WithPubSubTopic(msg.PubSubTopic), lightpush.WithPeer(serv.id))
_, err := serv.node.Lightpush().Publish(req.Context(), msg.Message, lightpush.WithPubSubTopic(msg.PubSubTopic))
writeErrOrResponse(w, err, true)
}
1 change: 0 additions & 1 deletion cmd/waku/server/rest/lightpush_rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func TestLightpushMessagev1(t *testing.T) {

router := chi.NewRouter()
serv := NewLightpushService(node2, router, utils.Logger())
// serv.id = node1.Host().ID()
_ = serv

msg := lightpushRequest{
Expand Down

0 comments on commit c9a339b

Please sign in to comment.