feat: Gotify CRUD + internal handler dispatch for notification service

- Add internal handler support to ServiceAdapter (Handler field)
- Dispatcher routes to internal handler when set (no reverse proxy)
- GotifyClient: full CRUD (send/list/delete messages, CRUD applications)
- Refactor notification handler: route by X-Resource header, not body format
- Register notification as ServiceAdapter with auth required
- Resources: send-email, send-message, list-messages, delete-message,
  delete-all-messages, list-applications, create-application, delete-application
- Update examples: sendmsg-email.sh, gotify-crud.sh
- Env vars: GOTIFY_URL, GOTIFY_APP_TOKEN, GOTIFY_CLIENT_TOKEN
This commit is contained in:
Admin Bot
2026-09-15 15:14:13 +09:00
parent 743148f576
commit 18e2031ab9
7 changed files with 605 additions and 207 deletions
+14 -30
View File
@@ -1,36 +1,20 @@
#!/bin/bash
# Example: Send email via notification/sendMsg endpoint
# Example: Send email via notification service (X-Service routing)
BASE_URL="${1:-https://api.riotpiao.com}"
AUTH_TOKEN="${2:-}" # Optional JWT token if auth required
AUTH_TOKEN="${2:-}"
PAYLOAD=$(cat <<'EOF'
{
"format": "smtp",
"title": "System Alert",
"message": "CPU usage exceeded 90% threshold",
"priority": 7,
"extras": {
"to_email": "[email protected]",
"cc": "[email protected]"
}
}
EOF
)
if [ -n "$AUTH_TOKEN" ]; then
curl -X POST "$BASE_URL" \
-H "X-Service: notification" \
-H "X-Resource: sendMsg" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-d "$PAYLOAD"
else
curl -X POST "$BASE_URL" \
-H "X-Service: notification" \
-H "X-Resource: sendMsg" \
-H "Content-Type: application/json" \
-d "$PAYLOAD"
fi
# Send email
curl -s -X POST "$BASE_URL" \
-H "X-Service: notification" \
-H "X-Resource: send-email" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-d '{
"to": "[email protected]",
"cc": "[email protected]",
"subject": "System Alert",
"body": "CPU usage exceeded 90% threshold"
}' | jq .
echo ""