# ─── отправка результата в БД (edge function autocall-result) ─────── # Переменные приходят из call-файла (Setvar). При потере сети звонок не # валится: curl с таймаутом, результат всё равно остался в $OUT. if [ -n "$API_URL" ] && [ -n "$API_KEY" ]; then curl -s --max-time 5 -X POST "$API_URL" \ -H "Content-Type: application/json" \ -H "x-webhook-secret: $API_KEY" \ -d "{ \"asterisk_uniqueid\":\"$UNIQ\", \"order_group_id\":\"${GROUP_ID:-}\", \"campaign_type\":\"autocall_slot\", \"customer_phone\":\"${CUSTOMER_PHONE:-}\", \"attempt_no\":${ATTEMPT:-1}, \"scenario\":\"$SCENARIO\", \"call_started_at\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\", \"answered_at\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\", \"duration_sec\":0, \"sip_code\":200, \"channel_state\":\"Up\", \"dtmf_day\":${CONF_DAY:-null}, \"dtmf_half\":${CONF_HALF:-null}, \"changed\":\"$CHANGED\", \"outcome\":\"$OUTCOME\", \"was_test_mode\":${TEST_MODE:-0} }" >/dev/null 2>&1 || echo "curl result failed (network?)" >> "$LOG" fi