diff --git a/go.mod b/go.mod index 841f625..8f6a65d 100644 --- a/go.mod +++ b/go.mod @@ -1,15 +1,14 @@ -module github.com/fiatjaf/nostr-relay +module github.com/fiatjaf/relayer go 1.15 require ( - github.com/fiatjaf/go-nostr v0.1.1 + github.com/fiatjaf/go-nostr v0.1.4 github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.4.2 github.com/jmoiron/sqlx v1.3.1 github.com/kelseyhightower/envconfig v1.4.0 github.com/lib/pq v1.8.0 - github.com/mattn/go-sqlite3 v1.14.6 github.com/rs/cors v1.7.0 github.com/rs/zerolog v1.20.0 ) diff --git a/go.sum b/go.sum index 55ced9e..39fbc48 100644 --- a/go.sum +++ b/go.sum @@ -17,8 +17,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fiatjaf/bip340 v1.0.0 h1:mpwbm+0KC9BXB/7/pnac4e4N1TiuppyEVXxtVAXj75k= github.com/fiatjaf/bip340 v1.0.0/go.mod h1:MxAz+5FQUTW4OT2gnCBC6Our486wmqf72ykZIrh7+is= -github.com/fiatjaf/go-nostr v0.1.1 h1:mMUn+Dr0QfhM1JuBHcGvvV0ON/tkinvOfXF8Yh825Xc= -github.com/fiatjaf/go-nostr v0.1.1/go.mod h1:Zwa4KwVMy3gLoMbbrH+NOZvqmrDADCIV+C67ew7VEqs= +github.com/fiatjaf/go-nostr v0.1.4 h1:OicdiaKBgt8UaI3/Eh+TIcC1uuMlXJMl+5IU7QqmgYo= +github.com/fiatjaf/go-nostr v0.1.4/go.mod h1:Zwa4KwVMy3gLoMbbrH+NOZvqmrDADCIV+C67ew7VEqs= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= diff --git a/postgresql.go b/postgresql.go index ccf8ef8..b145b6a 100644 --- a/postgresql.go +++ b/postgresql.go @@ -29,4 +29,4 @@ CREATE UNIQUE INDEX IF NOT EXISTS pubkeytimeidx ON event (pubkey, created_at); return db, nil } -const relatedEventsCondition = `tags @@ '$[*][1] == "' || ? || '"'` +const tagConditions = `jsonb_path_match(tags, '$[*][1] == $value', jsonb_build_object('value', ?::text))` diff --git a/query.go b/query.go index a10b820..3e406da 100644 --- a/query.go +++ b/query.go @@ -55,12 +55,12 @@ func queryEvents(filter *filter.EventFilter) (events []event.Event, err error) { } if filter.TagEvent != "" { - conditions = append(conditions, relatedEventsCondition) + conditions = append(conditions, tagConditions) params = append(params, filter.TagEvent) } if filter.TagProfile != "" { - conditions = append(conditions, relatedEventsCondition) + conditions = append(conditions, tagConditions) params = append(params, filter.TagProfile) }