recommendServer method

Event recommendServer(
  1. String url
)

Publishes a recommend_server event.

url is the URL of the relay being recommended.

Note that the transmission of the event to connected relays occurs asynchronously. nostr_dart maintains a message queue for each relay so that messages will be sent one at a time only after the previous message has acknowledged by the relay or a timeout occurs. This requires relays used to support NIP-15 and NIP-20.

The Event returned is the Nostr event that was published.

An ArgumentError is thrown if the private key hasn't been set or if url is not a valid relay URL.

Example:

var event = nostr.recommendServer('wss://example.com');

Implementation

Event recommendServer(String url) {
  if (!url.contains(RegExp(
      r'^(wss?:\/\/)([0-9]{1,3}(?:\.[0-9]{1,3}){3}|[^:]+):?([0-9]{1,5})?$'))) {
    throw ArgumentError.value(url, 'url', 'Not a valid relay URL');
  }
  final event = Event(_publicKey, EventKind.recommendServer, [], url);
  return sendEvent(event);
}