mirror of
https://github.com/aljazceru/haven.git
synced 2025-12-17 05:44:20 +01:00
26 lines
503 B
Go
26 lines
503 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"time"
|
|
|
|
"github.com/nbd-wtf/go-nostr"
|
|
)
|
|
|
|
func blast(ev *nostr.Event) {
|
|
ctx := context.Background()
|
|
for _, url := range config.BlastrRelays {
|
|
ctx, cancel := context.WithTimeout(ctx, time.Second*5)
|
|
relay, err := pool.EnsureRelay(url)
|
|
if err != nil {
|
|
cancel()
|
|
log.Println("error connecting to relay", relay, err)
|
|
continue
|
|
}
|
|
relay.Publish(ctx, *ev)
|
|
cancel()
|
|
}
|
|
log.Println("🔫 blasted", ev.ID, "to", len(config.BlastrRelays), "relays")
|
|
}
|