From 36eb6afa729fb1db3c04cde02580ee88db353bc8 Mon Sep 17 00:00:00 2001 From: Laan Tungir Date: Tue, 28 Jul 2026 09:38:53 -0400 Subject: [PATCH] Handle NOTICE and CLOSED messages in synchronous_query_relays_with_progress Pass NOTICE and CLOSED message content to the callback so callers can see what the relay actually said (e.g. auth-required, restricted, rate-limited). Previously these messages were silently ignored. --- nostr_core/core_relays.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/nostr_core/core_relays.c b/nostr_core/core_relays.c index 392fee8a..e30ca32e 100644 --- a/nostr_core/core_relays.c +++ b/nostr_core/core_relays.c @@ -322,6 +322,23 @@ cJSON** synchronous_query_relays_with_progress( nostr_ws_close(relay->client); relay->client = NULL; } + } else if (msg_type && (strcmp(msg_type, "NOTICE") == 0 || + strcmp(msg_type, "CLOSED") == 0)) { + /* Capture NOTICE and CLOSED messages from the relay. + * These often contain auth-required or restriction + * notices. Pass the message content to the callback. */ + const char* notice_msg = ""; + if (cJSON_IsArray(parsed) && cJSON_GetArraySize(parsed) >= 2) { + cJSON* msg_json = cJSON_GetArrayItem(parsed, 1); + if (msg_json && cJSON_IsString(msg_json)) { + notice_msg = cJSON_GetStringValue(msg_json); + } + } + if (callback) { + callback(relay->url, msg_type, notice_msg, + relay->events_received, relay_count, + completed_relays, user_data); + } } if (msg_type) free(msg_type);