#!/usr/bin/env bash # Points OpenZaak's own NotificationsConfig straight at this repo's BFF webhook # (POST /api/v1/zgw/notificaties) instead of standing up a real Notificaties API (NRC) # + abonnement — see docker-compose.openzaak.notificaties.yml's ponytail note for why. Requires # that overlay running (adds the celery worker + flips NOTIFICATIONS_DISABLED) AND the repo # root's own `docker compose up` running (the overlay joins its `api` container's network — # tried host.docker.internal first, but this harness's celery worker couldn't reach a # host-bound port through it; see the overlay's comment) with # Zgw__NotificatieAuthorization=$BFF_AUTH set on that `api` service. # # Idempotent: `update_or_create` on the Service's fixed slug, same shape as bootstrap-catalogus.sh. set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" COMPOSE_FILES=(-f docker-compose.openzaak.yml -f docker-compose.openzaak.notificaties.yml) # Container-to-container (the celery worker reaching the root project's `api` container by # name, see the overlay file) — this script itself runs on the HOST though, so its own # preflight check below hits the BFF at $BFF_LOCAL_ROOT (localhost, the published port) instead. BFF_API_ROOT="${BFF_API_ROOT:-http://api:5000/api/v1/zgw/}" BFF_LOCAL_ROOT="${BFF_LOCAL_ROOT:-http://localhost:5000/api/v1/zgw/}" BFF_AUTH="${BFF_AUTH:-wp-58-local-harness-not-for-prod}" echo "Preflight: is the BFF reachable at $BFF_LOCAL_ROOT with the shared secret configured?" status=$(curl -sS -o /dev/null -w '%{http_code}' -X POST \ -H "Authorization: $BFF_AUTH" -H 'Content-Type: application/json' \ -d '{"kanaal":"preflight","hoofdObject":"http://example.com/preflight","resource":"status","resourceUrl":"http://example.com/preflight","actie":"create","aanmaakdatum":"2026-01-01T00:00:00Z","kenmerken":{}}' \ "${BFF_LOCAL_ROOT}notificaties") if [ "$status" != "204" ]; then echo "FAILED: expected 204 from the BFF's webhook, got $status. From the repo root:" >&2 echo " docker compose run --rm -d --name atomic-design-poc-api-1 --service-ports \\" >&2 echo " -e Zgw__NotificatieAuthorization='$BFF_AUTH' api" >&2 exit 1 fi echo " ok (204)" docker compose "${COMPOSE_FILES[@]}" exec -T --workdir /app/src web python manage.py shell < {service.api_root}") PY echo echo "Notifications configured. Run ./verify-notificatie.sh to prove a live delivery."