Browse Source

Implement server-side event pushing for NIP-77 negentropy sync (v0.55.6)

- Implement sendEventsForIDs to actually send events via EVENT envelopes
- Previously this was a TODO stub that only logged "would send"
- Server now fetches and sends identified "have" events to clients

Files modified:
- pkg/version/version: Bump to v0.55.6
- app/handle-negentropy.go: Implement sendEventsForIDs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
main v0.55.6
woikos 4 months ago
parent
commit
36e681c5f3
No known key found for this signature in database
  1. 42
      app/handle-negentropy.go
  2. 2
      pkg/version/version

42
app/handle-negentropy.go

@ -11,6 +11,7 @@ import (
"lol.mleku.dev/log" "lol.mleku.dev/log"
"git.mleku.dev/mleku/nostr/encoders/filter" "git.mleku.dev/mleku/nostr/encoders/filter"
"git.mleku.dev/mleku/nostr/encoders/tag"
commonv1 "next.orly.dev/pkg/proto/orlysync/common/v1" commonv1 "next.orly.dev/pkg/proto/orlysync/common/v1"
negentropygrpc "next.orly.dev/pkg/sync/negentropy/grpc" negentropygrpc "next.orly.dev/pkg/sync/negentropy/grpc"
) )
@ -268,10 +269,43 @@ func (l *Listener) sendNegErr(subscriptionID, reason string) error {
// sendEventsForIDs fetches and sends events for the given IDs // sendEventsForIDs fetches and sends events for the given IDs
func (l *Listener) sendEventsForIDs(subscriptionID string, ids [][]byte) error { func (l *Listener) sendEventsForIDs(subscriptionID string, ids [][]byte) error {
// TODO: Implement event fetching and sending via EVENT envelopes if len(ids) == 0 {
// For each ID, query the database and send the event return nil
// This would use the existing event broadcasting mechanism }
log.D.F("NEG: would send %d events for subscription %s", len(ids), subscriptionID)
log.I.F("NEG: sending %d events for subscription %s", len(ids), subscriptionID)
// Build filter with hex-encoded IDs
f := &filter.F{}
f.Ids = &tag.T{}
for _, id := range ids {
// IDs can be 32 bytes (full) or 16 bytes (truncated per NIP-77)
hexID := hex.EncodeToString(id)
f.Ids.T = append(f.Ids.T, []byte(hexID))
}
// Query events by IDs
ctx := l.ctx
events, err := l.Server.db.QueryEvents(ctx, f)
if err != nil {
log.E.F("NEG: failed to query events: %v", err)
return err
}
// Send each event via EVENT envelope
sent := 0
for _, ev := range events {
if ev == nil {
continue
}
if err := l.SendEvent(ev); err != nil {
log.W.F("NEG: failed to send event: %v", err)
continue
}
sent++
}
log.I.F("NEG: sent %d/%d events for subscription %s", sent, len(ids), subscriptionID)
return nil return nil
} }

2
pkg/version/version

@ -1 +1 @@
v0.55.5 v0.55.6

Loading…
Cancel
Save