opt: fix ntfy

This commit is contained in:
2025-12-30 14:36:34 +07:00
parent e969f3da44
commit 4a94742273
2 changed files with 309 additions and 1 deletions

View File

@@ -57,13 +57,27 @@ EOF
echo -e " ${YELLOW}${NC} Sending push notification..."
echo -e " ${YELLOW}${NC} Target: $NTFY_URL/$NTFY_TOPIC"
response=$(curl -s -w "\n%{http_code}" $auth_args -X POST "$NTFY_URL/$NTFY_TOPIC" \
# Capture curl response and exit code separately
set +e # Temporarily disable exit on error for curl
response=$(curl -s -w "\n%{http_code}" --http1.1 -k $auth_args -X POST "$NTFY_URL/$NTFY_TOPIC" \
-H "Title: $ICON $TITLE" \
-H "Priority: $priority" \
-H "Tags: $tags" \
-H "Click: $click_url" \
-H "Actions: view, Open Logs, $click_url, clear=true" \
-d "$rich_message" 2>&1)
curl_exit_code=$?
set -e # Re-enable exit on error
# Check if curl command itself failed
if [ $curl_exit_code -ne 0 ]; then
echo -e " ${RED}${NC} Failed to send notification (curl error: $curl_exit_code)"
if [ -n "$response" ]; then
echo -e " ${RED}Error:${NC} $response"
fi
echo ""
return 0 # Return success to prevent script failure
fi
http_code=$(echo "$response" | tail -n1)
response_body=$(echo "$response" | head -n -1)