mirror of
https://github.com/aljazceru/khatru.git
synced 2025-12-17 05:24:22 +01:00
add khatru.IsInternal() for dealing with internal calls specifically in QueryEvents()
This commit is contained in:
@@ -39,6 +39,7 @@ func (rl *Relay) handleDeleteRequest(ctx context.Context, evt *nostr.Event) erro
|
||||
continue
|
||||
}
|
||||
|
||||
ctx := context.WithValue(ctx, internalCallKey, struct{}{})
|
||||
for _, query := range rl.QueryEvents {
|
||||
ch, err := query(ctx, f)
|
||||
if err != nil {
|
||||
|
||||
@@ -107,6 +107,7 @@ func (em *expirationManager) checkExpiredEvents(ctx context.Context) {
|
||||
|
||||
heap.Pop(&em.events)
|
||||
|
||||
ctx := context.WithValue(ctx, internalCallKey, struct{}{})
|
||||
for _, query := range em.relay.QueryEvents {
|
||||
ch, err := query(ctx, nostr.Filter{IDs: []string{next.id}})
|
||||
if err != nil {
|
||||
|
||||
7
utils.go
7
utils.go
@@ -10,6 +10,7 @@ const (
|
||||
wsKey = iota
|
||||
subscriptionIdKey
|
||||
nip86HeaderAuthKey
|
||||
internalCallKey
|
||||
)
|
||||
|
||||
func RequestAuth(ctx context.Context) {
|
||||
@@ -40,6 +41,12 @@ func GetAuthed(ctx context.Context) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// IsInternalCall returns true when a call to QueryEvents, for example, is being made because of a deletion
|
||||
// or expiration request.
|
||||
func IsInternalCall(ctx context.Context) bool {
|
||||
return ctx.Value(internalCallKey) != nil
|
||||
}
|
||||
|
||||
func GetIP(ctx context.Context) string {
|
||||
conn := GetConnection(ctx)
|
||||
if conn == nil {
|
||||
|
||||
Reference in New Issue
Block a user