Skip to content

Commit

Permalink
rest relay: avoid publish messages without timestamp information
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivansete-status committed Nov 30, 2023
1 parent 72a1f8c commit 8968ee8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion waku/waku_api/rest/relay/handlers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ proc installRelayApiHandlers*(router: var RestRouter, node: WakuNode, cache: Mes
return error

var message: WakuMessage = reqWakuMessage.toWakuMessage(version = 0).valueOr:
return RestApiResponse.badRequest()
return RestApiResponse.badRequest($error)

# if RLN is mounted, append the proof to the message
if not node.wakuRlnRelay.isNil():
Expand Down
5 changes: 4 additions & 1 deletion waku/waku_api/rest/relay/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ proc toWakuMessage*(msg: RelayWakuMessage, version = 0): Result[WakuMessage, str
version = uint32(msg.version.get(version))
timestamp = msg.timestamp.get(0)

ok(WakuMessage(payload: payload, contentTopic: contentTopic, version: version, timestamp: timestamp))
if timestamp == 0:
return err("timestamp cannot be 0 or empty")

return ok(WakuMessage(payload: payload, contentTopic: contentTopic, version: version, timestamp: timestamp))


#### Serialization and deserialization
Expand Down

0 comments on commit 8968ee8

Please sign in to comment.