auto-sync via WEVIA git_sync_all intent 2026-04-20T02:27:40+02:00
Some checks failed
WEVAL NonReg / nonreg (push) Has been cancelled

This commit is contained in:
opus
2026-04-20 02:27:40 +02:00
parent a1bc1fff5b
commit a5abffb8be
10 changed files with 139 additions and 1 deletions

50
api/handlers/resend-dns-push.py Executable file
View File

@@ -0,0 +1,50 @@
#!/usr/bin/env python3
# Opus v5.9.2: Push Resend DNS records to Cloudflare wevup.app zone
import json, sys, urllib.request, urllib.error, os
email = sys.argv[1]
key = sys.argv[2]
zone = "53e067fbc5c532a142222d60f7ecda9d"
with open("/tmp/resend_details.json") as f:
details = json.load(f)
records = details.get("records", [])
created = []
skipped = []
failed = []
for rec in records:
rtype = rec.get("record","").upper()
name = rec.get("name","")
value = rec.get("value","")
priority = rec.get("priority")
body = {"type": rtype, "name": name, "content": value, "ttl": 1}
if priority is not None and rtype == "MX":
body["priority"] = priority
req = urllib.request.Request(
f"https://api.cloudflare.com/client/v4/zones/{zone}/dns_records",
data=json.dumps(body).encode(),
headers={"X-Auth-Email": email, "X-Auth-Key": key, "Content-Type": "application/json"},
method="POST"
)
try:
with urllib.request.urlopen(req, timeout=10) as resp:
d = json.loads(resp.read().decode())
if d.get("success"): created.append(f"{rtype} {name}")
else: failed.append(f"{rtype} {name}")
except urllib.error.HTTPError as e:
body2 = e.read().decode()
try:
err = json.loads(body2)
msg = err.get("errors",[{}])[0].get("message","")
if "already exists" in msg.lower():
skipped.append(f"{rtype} {name}")
else:
failed.append(f"{rtype} {name}: {msg[:80]}")
except:
failed.append(f"{rtype} {name}: HTTP {e.code}")
except Exception as ex:
failed.append(f"{rtype} {name}: {str(ex)[:60]}")
print(json.dumps({"created": created, "skipped": skipped, "failed": failed, "total_records": len(records)}))

View File

@@ -0,0 +1,60 @@
#!/bin/bash
# Opus v5.9.2 ULTIMATE: pass Full Access Resend key + do everything
MSG="$*"
NEW_KEY=$(echo "$MSG" | grep -oE 're_[a-zA-Z0-9_]{10,}' | head -1)
if [ -z "$NEW_KEY" ]; then
echo '{"ok":false,"error":"Pass a Full-Access Resend key. Usage: resend full setup re_YOURKEY","how_to_get_key":"https://resend.com/api-keys > Create API Key > Full Access"}'
exit 0
fi
PERM_TEST=$(curl -s -X GET "https://api.resend.com/domains" -H "Authorization: Bearer $NEW_KEY" --max-time 8)
if echo "$PERM_TEST" | grep -q "restricted_api_key"; then
echo "{\"ok\":false,\"error\":\"Key is still SEND-ONLY. Create FULL ACCESS key.\",\"detected\":$PERM_TEST}"
exit 0
fi
# Save key
echo -n "$NEW_KEY" | sudo tee /opt/wevia-brain/email-providers/resend.key > /dev/null
sudo chmod 600 /opt/wevia-brain/email-providers/resend.key
S95_B64=$(echo -n "$NEW_KEY" | base64 -w0)
curl -s -X POST https://wevads.weval-consulting.com/api/sentinel-brain.php --data-urlencode "action=exec" --data-urlencode "cmd=echo '$S95_B64' | base64 -d | sudo tee /opt/wevia-brain/email-providers/resend.key > /dev/null && sudo chmod 600 /opt/wevia-brain/email-providers/resend.key" --max-time 8 > /dev/null 2>&1
# Add domain
ADD=$(curl -s -X POST "https://api.resend.com/domains" -H "Authorization: Bearer $NEW_KEY" -H "Content-Type: application/json" -d '{"name":"wevup.app","region":"eu-west-1"}' --max-time 10)
DOMAIN_ID=$(echo "$ADD" | python3 -c 'import json,sys; d=json.loads(sys.stdin.read()); print(d.get("id",""))' 2>/dev/null)
if [ -z "$DOMAIN_ID" ]; then
LIST=$(curl -s -X GET "https://api.resend.com/domains" -H "Authorization: Bearer $NEW_KEY" --max-time 10)
DOMAIN_ID=$(echo "$LIST" | python3 -c 'import json,sys; d=json.loads(sys.stdin.read()); m=[x for x in d.get("data",[]) if x.get("name")=="wevup.app"]; print(m[0]["id"] if m else "")' 2>/dev/null)
fi
[ -z "$DOMAIN_ID" ] && { echo "{\"ok\":false,\"error\":\"No domain ID\",\"add_resp\":$ADD}"; exit 0; }
# Get records + create in CF
DETAILS=$(curl -s -X GET "https://api.resend.com/domains/$DOMAIN_ID" -H "Authorization: Bearer $NEW_KEY" --max-time 10)
echo "$DETAILS" > /tmp/resend_details.json
CF_EMAIL=$(sudo cat /etc/weval/secrets.env | grep ^CF_EMAIL= | cut -d= -f2)
CF_KEY=$(sudo cat /etc/weval/secrets.env | grep ^CF_API_TOKEN= | cut -d= -f2)
python3 /var/www/html/api/handlers/resend-dns-push.py "$CF_EMAIL" "$CF_KEY" > /tmp/dns_result.json 2>&1
DNS_RESULT=$(cat /tmp/dns_result.json)
sleep 3
VERIFY=$(curl -s -X POST "https://api.resend.com/domains/$DOMAIN_ID/verify" -H "Authorization: Bearer $NEW_KEY" --max-time 10)
sleep 5
FINAL=$(curl -s -X GET "https://api.resend.com/domains/$DOMAIN_ID" -H "Authorization: Bearer $NEW_KEY" --max-time 10)
STATE=$(echo "$FINAL" | python3 -c 'import json,sys; d=json.loads(sys.stdin.read()); print(d.get("status","unknown"))' 2>/dev/null)
cat <<JSONEOF
{
"ok": true,
"v": "V5.9.2-ULTIMATE-opus-20avr",
"ts": "$(date -Iseconds)",
"doctrine": "#7 ZERO MANUEL TOTAL",
"key_saved_dual": true,
"domain_id": "$DOMAIN_ID",
"dns_result": $DNS_RESULT,
"final_status": "$STATE",
"verify_response": $VERIFY
}
JSONEOF

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B

View File

@@ -1,7 +1,7 @@
{
"ok": true,
"version": "V83-business-kpi",
"ts": "2026-04-20T00:25:49+00:00",
"ts": "2026-04-20T00:27:19+00:00",
"summary": {
"total_categories": 7,
"total_kpis": 56,

View File

@@ -5984,5 +5984,18 @@
"status": "PENDING_APPROVAL",
"created_at": "2026-04-20T00:26:12+00:00",
"source": "opus4-autowire-early-v2"
},
"450": {
"name": "resend_ultimate",
"triggers": [
"resend full setup",
"resend ultimate",
"auto setup resend",
"configure resend complete"
],
"cmd": "\/var\/www\/html\/api\/handlers\/resend-ultimate-setup.sh",
"status": "PENDING_APPROVAL",
"created_at": "2026-04-20T00:27:37+00:00",
"source": "opus4-autowire-early-v2"
}
}

View File

@@ -0,0 +1,15 @@
<?php
return array (
'name' => 'resend_ultimate',
'triggers' =>
array (
0 => 'resend full setup',
1 => 'resend ultimate',
2 => 'auto setup resend',
3 => 'configure resend complete',
),
'cmd' => '/var/www/html/api/handlers/resend-ultimate-setup.sh',
'status' => 'EXECUTED',
'created_at' => '2026-04-20T00:27:37+00:00',
'source' => 'opus4-autowire-early-v2',
);