add khatru.IsInternal() for dealing with internal calls specifically in QueryEvents()

This commit is contained in:
fiatjaf
2025-04-03 23:06:57 -03:00
parent 8c9394993b
commit 2ae219a34c
3 changed files with 9 additions and 0 deletions

View File

@@ -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 {