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.
This commit is contained in:
Laan Tungir
2026-07-28 09:38:53 -04:00
parent 160421c673
commit 36eb6afa72
+17
View File
@@ -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);