Removing debug, saving successfully delivered mentions
This commit is contained in:
parent
d6a9519146
commit
9878573fe1
4 changed files with 4 additions and 121 deletions
|
|
@ -0,0 +1 @@
|
||||||
|
https://ritual.sh/blog/2026-01-06-week-3-bit-chilly-out/|https://enclose.horse/
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Load environment variables from .env file
|
|
||||||
if [ -f .env ]; then
|
|
||||||
export $(cat .env | grep -v '^#' | xargs)
|
|
||||||
else
|
|
||||||
echo "⚠️ Warning: .env file not found, using defaults"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use environment variables with fallback defaults
|
|
||||||
WEBMENTIONS_FILE="${WEBMENTIONS_FILE:-public/webmentions.json}"
|
|
||||||
SENT_CACHE="${SENT_CACHE:-.webmentions-sent}"
|
|
||||||
API_ENDPOINT="${API_ENDPOINT:-https://api.ritual.sh/webmention/send}"
|
|
||||||
API_KEY="${API_KEY:-your-secret-key}"
|
|
||||||
|
|
||||||
echo "DEBUG: Configuration"
|
|
||||||
echo "===================="
|
|
||||||
echo "API_ENDPOINT: $API_ENDPOINT"
|
|
||||||
echo "API_KEY: ${API_KEY:0:10}... (first 10 chars)"
|
|
||||||
echo "WEBMENTIONS_FILE: $WEBMENTIONS_FILE"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Read the webmentions JSON
|
|
||||||
if [ ! -f "$WEBMENTIONS_FILE" ]; then
|
|
||||||
echo "No webmentions.json found at $WEBMENTIONS_FILE"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get first mention for testing
|
|
||||||
first_mention=$(jq -c '.[0]' "$WEBMENTIONS_FILE")
|
|
||||||
source=$(echo "$first_mention" | jq -r '.source')
|
|
||||||
target=$(echo "$first_mention" | jq -r '.target')
|
|
||||||
|
|
||||||
echo "DEBUG: Testing with first webmention"
|
|
||||||
echo "====================================="
|
|
||||||
echo "Source: $source"
|
|
||||||
echo "Target: $target"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Create the JSON payload
|
|
||||||
payload=$(jq -n \
|
|
||||||
--arg auth "$API_KEY" \
|
|
||||||
--arg source "$source" \
|
|
||||||
--arg target "$target" \
|
|
||||||
'{auth: $auth, source: $source, target: $target}')
|
|
||||||
|
|
||||||
echo "DEBUG: Payload"
|
|
||||||
echo "=============="
|
|
||||||
echo "$payload" | jq '.'
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
echo "DEBUG: Sending request..."
|
|
||||||
echo "========================="
|
|
||||||
|
|
||||||
# Send with verbose output
|
|
||||||
response=$(curl -v -X POST "$API_ENDPOINT" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "$payload" \
|
|
||||||
2>&1)
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "DEBUG: Full Response"
|
|
||||||
echo "===================="
|
|
||||||
echo "$response"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Extract just the HTTP status and response body
|
|
||||||
http_status=$(echo "$response" | grep "< HTTP" | tail -1)
|
|
||||||
response_body=$(echo "$response" | sed -n '/^{/,/^}/p' | tail -1)
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "DEBUG: Parsed Results"
|
|
||||||
echo "====================="
|
|
||||||
echo "HTTP Status: $http_status"
|
|
||||||
echo "Response Body: $response_body"
|
|
||||||
|
|
@ -70,8 +70,8 @@ jq -c '.[]' "$WEBMENTIONS_FILE" | while read -r mention; do
|
||||||
|
|
||||||
http_code=$(echo "$response" | tail -n1)
|
http_code=$(echo "$response" | tail -n1)
|
||||||
|
|
||||||
# If successful, add to cache
|
# If successful (200, 201, or 202), add to cache
|
||||||
if [ "$http_code" = "200" ] || [ "$http_code" = "202" ]; then
|
if [ "$http_code" = "200" ] || [ "$http_code" = "201" ] || [ "$http_code" = "202" ]; then
|
||||||
echo "$key" >> "$SENT_CACHE"
|
echo "$key" >> "$SENT_CACHE"
|
||||||
echo "✓ Sent successfully"
|
echo "✓ Sent successfully"
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Simple test to verify API authentication
|
|
||||||
# Usage: ./test-webmention-auth.sh YOUR_API_KEY
|
|
||||||
|
|
||||||
API_KEY="${1:-your-secret-key}"
|
|
||||||
API_ENDPOINT="${API_ENDPOINT:-https://api.ritual.sh/webmention/send}"
|
|
||||||
|
|
||||||
echo "Testing webmention API authentication"
|
|
||||||
echo "======================================"
|
|
||||||
echo "Endpoint: $API_ENDPOINT"
|
|
||||||
echo "API Key: ${API_KEY:0:10}... (truncated)"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Test 1: Wrong auth (should get 401)
|
|
||||||
echo "Test 1: Wrong auth (expecting 401 Unauthorized)"
|
|
||||||
echo "------------------------------------------------"
|
|
||||||
curl -v -X POST "$API_ENDPOINT" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"auth":"wrong-key","source":"https://ritual.sh/test/","target":"https://example.com/test/"}' \
|
|
||||||
2>&1 | grep -E "(< HTTP|Unauthorized|error)"
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Test 2: Correct auth (should get 400 or 201 depending on whether endpoints exist)
|
|
||||||
echo "Test 2: Correct auth (expecting 400 'No endpoint found' or 201 success)"
|
|
||||||
echo "------------------------------------------------------------------------"
|
|
||||||
curl -v -X POST "$API_ENDPOINT" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{\"auth\":\"$API_KEY\",\"source\":\"https://ritual.sh/test/\",\"target\":\"https://example.com/test/\"}" \
|
|
||||||
2>&1 | grep -E "(< HTTP|success|error|endpoint)"
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Test 3: Missing auth (should get 401)
|
|
||||||
echo "Test 3: Missing auth (expecting 401 Unauthorized)"
|
|
||||||
echo "--------------------------------------------------"
|
|
||||||
curl -v -X POST "$API_ENDPOINT" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"source":"https://ritual.sh/test/","target":"https://example.com/test/"}' \
|
|
||||||
2>&1 | grep -E "(< HTTP|Unauthorized|error)"
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue