241 Commits

Author SHA1 Message Date
mattn
639c210661
support NIP-45 (#58) 2023-05-17 07:54:56 -03:00
Yasuhiro Matsumoto
c4a678da1e fix(rss-bridge): do not use OnInitialized 2023-05-08 12:49:11 -03:00
Yasuhiro Matsumoto
2771d9b8ba fix(all): use v2 module 2023-05-08 12:49:11 -03:00
Isaque Veras
523b11d068 fix(rss): fixing event creation date type 2023-05-06 15:36:41 -03:00
bndw
54001282d9 fix: async save event
Uses a non-request-scoped context for async event handling operations.

Fixes #50
2023-05-03 17:13:42 -03:00
bndw
ae641fd24d refactor(postgres): make SQL generation testable
Decouples the postgresql sql generation from the query execution.
This allows the logic for building sql to be unit tested without
access to a database.

This work was motivated when a client was not receiving events as
expected. In debugging I found that if a tag's value was an empty array,
then no query would be executed - and to my surprised no error is
raised either. I wanted to get a better sense of the current constraints on
when queries are and are not executed, but I had a hard time keeping the
code in my head. This led me to extracting the sql generation into its
own function and writing the unit tests that document its current
behavior. This refactor makes no changes to the current logic. I have added
some REVIEW comments in the test cases where I thought some error handling
could be introduced but I wanted to first see if you were receptive to this
refactor before proposing any functional changes.
2023-05-02 12:41:51 -03:00
fiatjaf
e84f5df1f0
make tests pass on base package. 2023-05-01 20:38:11 -03:00
fiatjaf
a4512da371
reimplement server.Start() 2023-05-01 19:56:37 -03:00
fiatjaf
4e15120111
migrate all built-in storage backends. 2023-05-01 19:41:17 -03:00
fiatjaf
e3d4655dba
v2 with breaking changes and a simpler API. 2023-05-01 19:21:09 -03:00
Steve Perkins
a82e5edb0d Adds NIP-33 support for replaceable events. 2023-03-31 11:36:54 -03:00
Liran Cohen
7ea3cd5431 unecessary check 2023-03-10 07:33:32 -03:00
Liran Cohen
ee301e82d9 like over instr 2023-03-10 07:33:32 -03:00
mattn
b50dad2700 fix link 2023-02-26 14:58:08 -03:00
mattn
0e7c7f8abb
add sqlite3 storage (#40)
* add sqlite3 storage

* filter by content

* remove needless files

* update go.mod

* do not unquote Search
2023-02-26 14:57:47 -03:00
fiatjaf
4fc77c2604
build and release search example relay. 2023-02-15 20:46:27 -03:00
fiatjaf
eb0c6539b6
update go-nostr dependency and gitignore search binary. 2023-02-15 20:27:51 -03:00
fiatjaf
50ad9de70b
Merge pull request #37 from stereosteve/elasticsearch 2023-02-15 18:34:14 -03:00
Steve Perkins
a7a0bb6682 Use dsl builder for es query 2023-02-15 16:29:54 -05:00
Steve Perkins
0e18a49861 wip docker-compose setup 2023-02-13 20:44:06 -05:00
Steve Perkins
05600231b4 support search req a-la nip-50 2023-02-10 14:58:01 -05:00
Gustavo Chain
9aeb352320 advertise nip11 on nip11 handler 2023-02-10 15:28:11 -03:00
Gustavo Chain
304831f749 move AfterSave method from relay to storage 2023-02-10 10:37:46 -03:00
Gustavo Chain
c7d584da54 remove duplicated nip09 handling 2023-02-09 06:54:37 -03:00
Steve Perkins
34a21cb374 Use bulk indexer for writes. Special case get by ID. 2023-02-07 10:46:27 -05:00
Steve Perkins
d306c03369 basic elasticsearch storage example 2023-02-06 13:30:51 -05:00
fiatjaf
905a68cd91
update dependencies. 2023-01-26 20:03:50 -03:00
Dylan Cant
d7750ad15f added comment 2023-01-19 17:56:28 -03:00
Dylan Cant
82e4174073 added filter handling to query.go and sort "created_by" descending 2023-01-19 17:56:28 -03:00
Liran Cohen
0442b02394 fix postgres delete event query 2023-01-18 18:33:06 -03:00
fiatjaf
e270b56314
Merge pull request #26 from barkyq/master
Small fixes to NIP-42 parts of handlers.go
2023-01-17 08:08:46 -03:00
Dylan Cant
23965269a1 Merge remote-tracking branch 'origin/master' 2023-01-16 21:32:28 -05:00
Dylan Cant
cab0654516 small fixes to NIP-42 parts of handlers.go
also removed "break" commands at ends of cases in switch
statement (these are unnecessary in `go`, cf https://go.dev/tour/flowcontrol/9)
2023-01-16 21:29:35 -05:00
Dylan Cant
38d0f481c1 Added an "OK" signal when authenticated (or not)
To interact with okCallback in go-nostr relay.go.
2023-01-16 08:26:41 -03:00
Dylan Cant
c05896a2e3 fixed typos added docstring 2023-01-16 08:26:41 -03:00
Dylan Cant
cf3f94f4de Added an "OK" signal when authenticated (or not)
To interact with okCallback in go-nostr relay.go.
2023-01-16 01:24:35 -05:00
Dylan Cant
c573c465f0 fixed typos added docstring 2023-01-15 23:33:53 -05:00
fiatjaf
fe91197d45
implement nip-42 AUTH and restrict DMs to authed users. 2023-01-15 22:38:24 -03:00
fiatjaf
e70a5601c7
update go-nostr and fix rss-bridge. 2023-01-02 14:31:28 -03:00
0x0ff
9ba958e9a0 set SetMaxOpenConns, close rows when QueryEvents finishes 2022-12-30 15:28:43 -03:00
0x0ff
8b3ff7ac26 fix: remove listeners when client disconnects 2022-12-29 13:59:19 -03:00
0x0ff
9ba4326085 fix: pass unix timestamp to DB.Exec instead of Time 2022-12-29 13:57:49 -03:00
0x0ff
af890590f3 fix: QueryEvents should skip ids that are not a valid 32 byte hex 2022-12-28 09:17:33 -03:00
0x0ff
f2ab8020a8 handle event responses as per NIP-20 2022-12-27 16:44:57 -03:00
Saul Freeberty
05e8f03d43 move timestamp variable under condition 2022-12-26 19:53:00 -03:00
Saul Freeberty
8fd148bbb5 remove expired invoice, and fix display unexpired invoice 2022-12-26 19:53:00 -03:00
Saul Freeberty
bacf19b88d remove empty space 2022-12-25 20:54:49 -03:00
Saul Freeberty
3c953e4ae8 fix expensive relay invoice handler 2022-12-25 20:54:49 -03:00
alex
627724f702 start: introduce Server type and Shutdown (breaking change)
the main motivation for this change is to be able to run tests.
before this commit, Start, Router and Log operated on global variables,
making automated testing unreasonably hard.

this commit puts all that a server needs in a new Server type,
which also made it possible for a Server.Shutdown - see ShutdownAware
doc comments.

BREAKING CHANGES:
- Relay.OnInitialized takes one argument now, *relayer.Server.
- relayer.Router is now replaced by relayer.Server.Router().
  package users can still hook into the router from OnInitialized
  for custom HTTP routing.
- relayer.Log is gone. apart from another global var, imho this was
  a too opinionated choice for a framework to build a custom relay upon.
  this commit introduces a Logger interface which package users can implement
  for zerolog to make it log like before. see Server.Log for details.

other notable changes: finally added a couple basic tests, for start up
and shutdown. doc comments now explain most of the essentials,
hopefully making it more approachable for newcomers and easier to understand
the relayer package.

the changes in handlers.go are minimal, although git diff goes crazy.
this is because most of the lines are simply shifted indentation back by one
due to go fmt.

before this commit:

    func handleWebsocket(relay Relay) func(http.ResponseWriter, *http.Request)
    func handleNIP11(relay Relay) func(http.ResponseWriter, *http.Request)

after:

    func (s *Server) handleWebsocket(w http.ResponseWriter, r *http.Request)
    func (s *Server) handleNIP11(w http.ResponseWriter, r *http.Request)
2022-12-24 20:41:02 -03:00
alex
932a9b62a7
start: make http server's listening host/port compatible with IPv6 (#14)
previously, a command like this to listen on IPv6 loopback:

    HOST=::1 PORT=7447 go run ./basic/

would exit immediately because ::1:7447 is an invalid address.

IPv6 addresses contain columns, so a simple host + port concatenation
doesn't work. net.JoinHostPort is a function to do exactly that.
2022-12-24 18:53:05 -03:00