khatru: OnAuth hook.
This commit is contained in:
@@ -346,6 +346,9 @@ func (rl *Relay) HandleWebsocket(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
ws.authLock.Unlock()
|
ws.authLock.Unlock()
|
||||||
ws.WriteJSON(nostr.OKEnvelope{EventID: env.Event.ID, OK: true})
|
ws.WriteJSON(nostr.OKEnvelope{EventID: env.Event.ID, OK: true})
|
||||||
|
if rl.OnAuth != nil {
|
||||||
|
rl.OnAuth(ctx, pubkey)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ws.WriteJSON(nostr.OKEnvelope{EventID: env.Event.ID, OK: false, Reason: "error: failed to authenticate: " + err.Error()})
|
ws.WriteJSON(nostr.OKEnvelope{EventID: env.Event.ID, OK: false, Reason: "error: failed to authenticate: " + err.Error()})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ type Relay struct {
|
|||||||
RejectConnection func(r *http.Request) bool
|
RejectConnection func(r *http.Request) bool
|
||||||
OnConnect func(ctx context.Context)
|
OnConnect func(ctx context.Context)
|
||||||
OnDisconnect func(ctx context.Context)
|
OnDisconnect func(ctx context.Context)
|
||||||
|
OnAuth func(ctx context.Context, pubkey nostr.PubKey)
|
||||||
OnListenerAdded func(ws *WebSocket, ssid int, id string, filter nostr.Filter)
|
OnListenerAdded func(ws *WebSocket, ssid int, id string, filter nostr.Filter)
|
||||||
OnListenerRemoved func(ws *WebSocket, ssid int, id string, filter nostr.Filter)
|
OnListenerRemoved func(ws *WebSocket, ssid int, id string, filter nostr.Filter)
|
||||||
OverwriteRelayInformation func(ctx context.Context, r *http.Request, info nip11.RelayInformationDocument) nip11.RelayInformationDocument
|
OverwriteRelayInformation func(ctx context.Context, r *http.Request, info nip11.RelayInformationDocument) nip11.RelayInformationDocument
|
||||||
|
|||||||
Reference in New Issue
Block a user