cameri / nostream

A Nostr Relay written in TypeScript
MIT License
715 stars 185 forks source link

[BUG] Relay is not accepting Text Events #284

Closed sroertgen closed 1 year ago

sroertgen commented 1 year ago

Describe the bug With the current version (commit https://github.com/Cameri/nostream/commit/fb6948fd83ca87ce552f39f9b5eb780ea07e272e) nostream is not accepting events. Sending a simple event with nostr-tools gives no response. Requesting events works as expected though.

Switching to commit https://github.com/Cameri/nostream/commit/f23740073f6b59b230157528376a89ca44af3f27 solves the issue. Everything works as expected.

To Reproduce Steps to reproduce the behavior:

  1. Run command:
    • Start nostream witch mentioned commit checked out
    • execute sth like:
      
      import 'websocket-polyfill'
      import {
      relayInit,
      getPublicKey,
      getEventHash,
      signEvent
      } from 'nostr-tools'

const relay = relayInit('wss://example.com') let privateKey = 'xxx'

relay.on('connect', () => { console.log(connected to ${relay.url}) }) relay.on('error', () => { console.log(failed to connect to ${relay.url}) })

await relay.connect()

let event = { kind: 1, created_at: Math.floor(Date.now() / 1000), tags: [], content: 'Hello world! This is a test', pubkey: getPublicKey(privateKey) }

event.id = getEventHash(event) event.sig = signEvent(event, privateKey)

let pub = relay.publish(event) pub.on('ok', () => { console.log(${relay.url} has accepted our event) }) pub.on('failed', reason => { console.log(failed to publish to ${relay.url}: ${reason}) })


2. See error: Event is not accepted, but no error is thrown either.

**Expected behavior**
The event got accepted

**System (please complete the following information):**
 - OS: Ubuntu 22.04
 - Platform: docker
 - Version: commit https://github.com/Cameri/nostream/commit/fb6948fd83ca87ce552f39f9b5eb780ea07e272e
sroertgen commented 1 year ago

The error seemed to stem from a missing environment variable SECRET, which is by now mandatory.

After adding that everything works as expected.

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 1.23.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: