relayer icon indicating copy to clipboard operation
relayer copied to clipboard

Change accept event return type

Open arejula27 opened this issue 2 years ago • 9 comments

Currently the onAccept event returns a Boolean. What about changing it type to error or some new type. This could help implement nip20.

arejula27 avatar Dec 17 '22 23:12 arejula27

Maybe creating a new type "Command result" will be more correct. If u agree I can do it.

arejula27 avatar Dec 17 '22 23:12 arejula27

Let me do it myself, I'll look at this better.

fiatjaf avatar Dec 18 '22 01:12 fiatjaf

Well, if u need help with something just assign me some issues and I will try when have time available 👌

arejula27 avatar Dec 18 '22 09:12 arejula27

I just came across this issue after opening a PR: https://github.com/fiatjaf/relayer/pull/13

I see that there are still a few places in handlers.go where we return a message via s.WriteJSON([]interface{}{"OK", evt.ID, false, ... perhaps I should refactor that code (within my PR) to return that custom error in CheckSignature and DeleteEvent (somewhere else?) and handle it similarly as I handle it here.

Note that I'm not programming in go often so if my code it shit and this should be done differently, let me know on my PR.

katsucodes247 avatar Dec 23 '22 16:12 katsucodes247

Ah, I see that CheckSignature and DeleteEvent are func in nbd-wtf lib. Would it make sense to move the errors.go code from this PR into nbd-wtf?

katsucodes247 avatar Dec 23 '22 16:12 katsucodes247

How is going?

arejula27 avatar Dec 31 '22 01:12 arejula27

I am confused.

fiatjaf avatar Dec 31 '22 02:12 fiatjaf

need help?

arejula27 avatar Dec 31 '22 11:12 arejula27

agreed that: (r *Relay) AcceptEvent(*nostr.Event) bool could be changed to (r *Relay) AcceptEvent(*nostr.Event) error in interfaces.go, to allow for better messaging of why the event was not accepted (e.g., duplicate event, too big, etc).

barkyq avatar Jan 18 '23 18:01 barkyq