v0.7.5 - Complete debug logging cleanup - remove all remaining DEBUG messages from websockets.c, config.c, and dm_admin.c

This commit is contained in:
Your Name
2025-10-10 10:52:14 -04:00
parent c90676d2b2
commit 00d16f8615
4 changed files with 40 additions and 170 deletions

View File

@@ -1597,11 +1597,6 @@ int process_nip17_admin_command(cJSON* dm_event, char* error_message, size_t err
const char* admin_pubkey = get_admin_pubkey_cached();
int is_admin = admin_pubkey && strlen(admin_pubkey) > 0 && strcmp(sender_pubkey, admin_pubkey) == 0;
log_info("NIP-17: Processing admin command from DM content");
char log_msg[256];
snprintf(log_msg, sizeof(log_msg), "NIP-17: Received DM content: '%.50s'%s", dm_content, strlen(dm_content) > 50 ? "..." : "");
log_info(log_msg);
// Parse DM content as JSON array of commands
cJSON* command_array = cJSON_Parse(dm_content);
if (!command_array || !cJSON_IsArray(command_array)) {
@@ -1623,9 +1618,6 @@ int process_nip17_admin_command(cJSON* dm_event, char* error_message, size_t err
// Check for stats commands
if (strstr(content_lower, "stats") != NULL || strstr(content_lower, "statistics") != NULL) {
log_info("NIP-17: Recognized plain text 'stats' command from admin");
log_info("NIP-17: Action: Generate and send relay statistics");
char* stats_text = generate_stats_text();
if (!stats_text) {
return -1;
@@ -1639,15 +1631,11 @@ int process_nip17_admin_command(cJSON* dm_event, char* error_message, size_t err
log_error(error_msg);
return -1;
}
log_success("NIP-17: Stats command processed successfully, response sent");
return 0;
}
// Check for config commands
else if (strstr(content_lower, "config") != NULL || strstr(content_lower, "configuration") != NULL) {
log_info("NIP-17: Recognized plain text 'config' command from admin");
log_info("NIP-17: Action: Generate and send relay configuration");
char* config_text = generate_config_text();
if (!config_text) {
return -1;
@@ -1661,8 +1649,7 @@ int process_nip17_admin_command(cJSON* dm_event, char* error_message, size_t err
log_error(error_msg);
return -1;
}
log_success("NIP-17: Config command processed successfully, response sent");
return 0;
}
else {
@@ -1670,7 +1657,7 @@ int process_nip17_admin_command(cJSON* dm_event, char* error_message, size_t err
int confirmation_result = handle_config_confirmation(sender_pubkey, dm_content);
if (confirmation_result != 0) {
if (confirmation_result > 0) {
log_success("NIP-17: Configuration confirmation processed successfully");
// Configuration confirmation processed successfully
} else if (confirmation_result == -2) {
// No pending changes
char no_pending_msg[256];
@@ -1691,7 +1678,6 @@ int process_nip17_admin_command(cJSON* dm_event, char* error_message, size_t err
int config_result = process_config_change_request(sender_pubkey, dm_content);
if (config_result != 0) {
if (config_result > 0) {
log_success("NIP-17: Configuration change request processed successfully");
return 1; // Return positive value to indicate response was handled
} else {
log_error("NIP-17: Configuration change request failed");
@@ -1699,12 +1685,10 @@ int process_nip17_admin_command(cJSON* dm_event, char* error_message, size_t err
}
}
log_info("NIP-17: Plain text content from admin not recognized as command, treating as user DM");
return 0; // Admin sent unrecognized plain text, treat as user DM
}
} else {
// Not admin, treat as user DM
log_info("NIP-17: Content is not JSON array and sender is not admin, treating as user DM");
return 0;
}
}
@@ -1713,8 +1697,6 @@ int process_nip17_admin_command(cJSON* dm_event, char* error_message, size_t err
if (cJSON_GetArraySize(command_array) > 0) {
cJSON* first_item = cJSON_GetArrayItem(command_array, 0);
if (cJSON_IsString(first_item) && strcmp(cJSON_GetStringValue(first_item), "stats") == 0) {
log_info("NIP-17: Processing 'stats' command directly");
// Get sender pubkey for response
cJSON* sender_pubkey_obj = cJSON_GetObjectItem(dm_event, "pubkey");
if (!sender_pubkey_obj || !cJSON_IsString(sender_pubkey_obj)) {
@@ -1742,8 +1724,7 @@ int process_nip17_admin_command(cJSON* dm_event, char* error_message, size_t err
strncpy(error_message, error_msg, error_size - 1);
return -1;
}
log_success("NIP-17: Stats command processed successfully");
return 0;
}
}