Replace was not working as expected, should no be fixed. Mess has to be cleaned up

This commit is contained in:
@s.roertgen 2025-03-28 15:01:25 +01:00
parent 5d0be447f0
commit 47b5e2fb56
3 changed files with 63 additions and 31 deletions

30
main.go
View file

@ -37,9 +37,8 @@ func main() {
khatru.RequestAuth(ctx)
})
relay.StoreEvent = append(relay.StoreEvent)
relay.QueryEvents = append(relay.QueryEvents, handleQuery)
relay.CountEvents = append(relay.CountEvents, dbts.CountEvents) // use badger for counting events -> TODO switch to typesense?
relay.CountEvents = append(relay.CountEvents, handleCount)
relay.DeleteEvent = append(relay.DeleteEvent, handleDelete)
relay.ReplaceEvent = append(relay.ReplaceEvent, handleReplaceEvent)
relay.Negentropy = true
@ -57,16 +56,6 @@ func main() {
http.ListenAndServe(":3334", relay)
}
func handleDelete(ctx context.Context, event *nostr.Event) error {
DeleteNostrEvent(collectionName, event)
return nil
}
func handleReplaceEvent(ctx context.Context, event *nostr.Event) error {
IndexNostrEvent(collectionName, event)
return nil
}
func handleQuery(ctx context.Context, filter nostr.Filter) (chan *nostr.Event, error) {
ch := make(chan *nostr.Event)
@ -84,3 +73,20 @@ func handleQuery(ctx context.Context, filter nostr.Filter) (chan *nostr.Event, e
}()
return ch, nil
}
func handleCount(ctx context.Context, filter nostr.Filter) (int64, error) {
CountEvents(collectionName, filter)
return 0, nil
}
func handleDelete(ctx context.Context, event *nostr.Event) error {
fmt.Println("delete event", event)
DeleteNostrEvent(collectionName, event)
return nil
}
func handleReplaceEvent(ctx context.Context, event *nostr.Event) error {
IndexNostrEvent(collectionName, event)
return nil
}