| @@ -613,8 +613,29 @@ | ||
| 613 | 613 | //error_log('MXChat Save: Processing live_agent_status'); |
| 614 | 614 | // Set the new value |
| 615 | 615 | $options[$field_name] = ($value === 'on') ? 'on' : 'off'; |
| 616 | 616 | break; |
| 617 | + // Shared handoff channel (plan 1a2666): re-probe the channel's privacy | |
| 618 | + // at configuration time so the settings screen can warn about private | |
| 619 | + // channels (their inbound events arrive as message.groups, which the | |
| 620 | + // documented app setup never subscribes to). Only id-shaped values can | |
| 621 | + // be checked before the first handoff resolves a #name — the handoff | |
| 622 | + // path probes those when it caches the resolved id. | |
| 623 | + case 'live_agent_shared_channel': | |
| 624 | + $options[$field_name] = sanitize_text_field($value); | |
| 625 | + delete_option('mxchat_slack_shared_channel_privacy'); | |
| 626 | + $shared_channel_target = ltrim(trim((string) $options[$field_name]), '#'); | |
| 627 | + if ($shared_channel_target !== '' && preg_match('/^[CG][A-Z0-9]{6,}$/', $shared_channel_target)) { | |
| 628 | + if (!class_exists('MxChat_Integrator')) { | |
| 629 | + require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-mxchat-integrator.php'; | |
| 630 | + } | |
| 631 | + MxChat_Integrator::mxchat_probe_slack_channel_privacy( | |
| 632 | + $options['live_agent_bot_token'] ?? '', | |
| 633 | + $shared_channel_target, | |
| 634 | + trim((string) $options[$field_name]) | |
| 635 | + ); | |
| 636 | + } | |
| 637 | + break; | |
| 617 | 638 | // Webhook handoff destination (plan d88e22). Status normalized like the |
| 618 | 639 | // other channel toggles; the URL is refused outright when it isn't |
| 619 | 640 | // https so the admin hears about it at save time instead of the |
| 620 | 641 | // handoff silently never firing. |
| @@ -1035,8 +1056,36 @@ | ||
| 1035 | 1056 | $new_value = sanitize_text_field($value); |
| 1036 | 1057 | if ($field_name === 'mxchat_pinecone_host') { |
| 1037 | 1058 | $new_value = str_replace(['https://', 'http://'], '', $new_value); |
| 1038 | 1059 | } |
| 1060 | + break; | |
| 1061 | + case 'mxchat_pinecone_index_type': | |
| 1062 | + // 362c31: document only once the host has been checked (see sanitize_pinecone_settings). | |
| 1063 | + $new_value = ($value === 'document') ? 'document' : 'vector'; | |
| 1064 | + if ($new_value === 'document' && strtolower(trim((string) ($current_options['mxchat_pinecone_host'] ?? ''), '/')) !== strtolower((string) ($current_options['mxchat_pinecone_docs_verified_host'] ?? ''))) { | |
| 1065 | + wp_send_json_error(['message' => esc_html__('Check the document index host first (Check index or Create index for me).', 'mxchat')]); | |
| 1066 | + } | |
| 1067 | + // 3e83e4: same gate as the form save — no switch onto a half-copied index. | |
| 1068 | + if ($new_value === 'document' && (($current_options['mxchat_pinecone_index_type'] ?? 'vector') !== 'document') && class_exists('MxChat_Pinecone_Documents')) { | |
| 1069 | + $running = MxChat_Pinecone_Documents::migration_blocks_switch((string) ($current_options['mxchat_pinecone_host'] ?? '')); | |
| 1070 | + if ($running !== null) { | |
| 1071 | + wp_send_json_error(['message' => MxChat_Pinecone_Documents::switch_blocked_message($running)]); | |
| 1072 | + } | |
| 1073 | + } | |
| 1074 | + break; | |
| 1075 | + case 'mxchat_pinecone_vector_host': | |
| 1076 | + $new_value = trim(str_replace(['https://', 'http://'], '', sanitize_text_field($value)), '/'); | |
| 1077 | + break; | |
| 1078 | + case 'mxchat_pinecone_vector_index': | |
| 1079 | + case 'mxchat_pinecone_docs_region': | |
| 1080 | + $new_value = sanitize_text_field($value); | |
| 1081 | + break; | |
| 1082 | + case 'mxchat_pinecone_docs_cloud': | |
| 1083 | + $new_value = in_array($value, array('aws', 'gcp', 'azure'), true) ? $value : 'aws'; | |
| 1084 | + break; | |
| 1085 | + case 'mxchat_pinecone_docs_language': | |
| 1086 | + $lang_value = sanitize_key($value); | |
| 1087 | + $new_value = (class_exists('MxChat_Pinecone_Documents') && array_key_exists($lang_value, MxChat_Pinecone_Documents::languages())) ? $lang_value : 'en'; | |
| 1039 | 1088 | break; |
| 1040 | 1089 | case 'mxchat_pinecone_top_k': |
| 1041 | 1090 | // d0cae1: out-of-range and junk normalize to the default 50 — |
| 1042 | 1091 | // same clamp the read site applies. |