mirror of
https://github.com/aljazceru/khatru.git
synced 2026-01-17 20:24:22 +01:00
Adds NIP-33 support for replaceable events.
This commit is contained in:
@@ -2,6 +2,7 @@ package sqlite3
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/fiatjaf/relayer/storage"
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
@@ -16,6 +17,13 @@ func (b *SQLite3Backend) SaveEvent(evt *nostr.Event) error {
|
||||
// delete past recommend_server events equal to this one
|
||||
b.DB.Exec(`DELETE FROM event WHERE pubkey = $1 AND kind = $2 AND content = $3`,
|
||||
evt.PubKey, evt.Kind, evt.Content)
|
||||
} else if evt.Kind >= 30000 && evt.Kind < 40000 {
|
||||
// NIP-33
|
||||
d := evt.Tags.GetFirst([]string{"d"})
|
||||
if d != nil {
|
||||
tagsLike := fmt.Sprintf(`%%"d","%s"%%`, d.Value())
|
||||
b.DB.Exec(`DELETE FROM event WHERE pubkey = $1 AND kind = $2 AND tags LIKE $3`, evt.PubKey, evt.Kind, tagsLike)
|
||||
}
|
||||
}
|
||||
|
||||
// insert
|
||||
|
||||
Reference in New Issue
Block a user