utils
utils
¶
Finder service utility functions.
Pure helpers for relay URL extraction from Nostr event data and API responses.
Classes¶
Functions¶
extract_urls_from_response
¶
Extract URL strings from a JSON API response via a JMESPath expression.
Applies expression to the parsed JSON data and filters the result to only string values. Validation (scheme, host, etc.) is left to the caller.
Parameters:
-
data(Any) –Parsed JSON response (any type).
-
expression(str, default:'[*]') –JMESPath expression that should evaluate to a list of strings. Defaults to
[*](identity on a flat list).
Returns:
-
list[str]–List of extracted URL strings (may contain duplicates or invalid
-
list[str]–values -- the caller decides how to validate them).
Source code in src/bigbrotr/services/finder/utils.py
extract_relays_from_rows
¶
extract_relays_from_rows(
rows: list[dict[str, Any]],
) -> dict[str, Relay]
Extract and deduplicate relay URLs from event tagvalues.
Parses every value in each row's tagvalues array via
parse_relay_url. Values that parse as valid relay URLs become
candidates; all others (hex IDs, pubkeys, hashtags, etc.) are
silently discarded.
Parameters:
-
rows(list[dict[str, Any]]) –Event rows with
tagvalueskey (fromfetch_event_tagvalues).
Returns: