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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user