v0.4.10 - api
This commit is contained in:
22
src/config.c
22
src/config.c
@@ -1,6 +1,7 @@
|
||||
#define _GNU_SOURCE
|
||||
#include "config.h"
|
||||
#include "default_config_event.h"
|
||||
#include "dm_admin.h"
|
||||
#include "../nostr_core_lib/nostr_core/nostr_core.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -2957,9 +2958,24 @@ int handle_kind_23456_unified(cJSON* event, char* error_message, size_t error_si
|
||||
printf(" Decrypted content: %s\n", decrypted_text);
|
||||
printf(" Decrypted length: %zu\n", strlen(decrypted_text));
|
||||
|
||||
// Parse decrypted content as inner event JSON (NIP-17)
|
||||
log_info("DEBUG: Parsing decrypted content as inner event JSON");
|
||||
cJSON* inner_event = cJSON_Parse(decrypted_text);
|
||||
// Check if decrypted content is a direct command array (DM control system)
|
||||
log_info("DEBUG: Checking if decrypted content is direct command array");
|
||||
cJSON* potential_command_array = cJSON_Parse(decrypted_text);
|
||||
|
||||
if (potential_command_array && cJSON_IsArray(potential_command_array)) {
|
||||
log_info("DEBUG: Detected direct command array - routing to DM admin system");
|
||||
printf(" Direct command array detected, size: %d\n", cJSON_GetArraySize(potential_command_array));
|
||||
|
||||
// Route to DM admin system
|
||||
int dm_result = process_dm_admin_command(potential_command_array, event, error_message, error_size, wsi);
|
||||
cJSON_Delete(potential_command_array);
|
||||
memset(decrypted_text, 0, sizeof(decrypted_text)); // Clear sensitive data
|
||||
return dm_result;
|
||||
}
|
||||
|
||||
// If not a direct command array, try parsing as inner event JSON (NIP-17)
|
||||
log_info("DEBUG: Not a direct command array, parsing as inner event JSON");
|
||||
cJSON* inner_event = potential_command_array; // Reuse the parsed JSON
|
||||
|
||||
if (!inner_event || !cJSON_IsObject(inner_event)) {
|
||||
log_error("DEBUG: Decrypted content is not valid inner event JSON");
|
||||
|
||||
Reference in New Issue
Block a user