|
|
@@ -1,33 +0,0 @@
|
|
|
-#!/bin/bash
|
|
|
-# Dovecot Sieve pipe target: reads an email from stdin, extracts the Extranet
|
|
|
-# code, and POSTs it to the room-cal SMS endpoint.
|
|
|
-#
|
|
|
-# Required env vars (set in /etc/dovecot/sieve-pipe-env or similar):
|
|
|
-# SMS_API_URL — base URL of the room-cal API, e.g. https://cal.example.com
|
|
|
-# SMS_GATEWAY_SECRET — value of SMS_GATEWAY_SECRET configured in the API
|
|
|
-
|
|
|
-set -euo pipefail
|
|
|
-
|
|
|
-API_URL="${SMS_API_URL:-}"
|
|
|
-SECRET="${SMS_GATEWAY_SECRET:-}"
|
|
|
-
|
|
|
-if [[ -z "$API_URL" ]]; then
|
|
|
- echo "sms_code_filter: SMS_API_URL not set" >&2
|
|
|
- exit 1
|
|
|
-fi
|
|
|
-
|
|
|
-# Read the full email from stdin and extract the first 6-digit Extranet code.
|
|
|
-email=$(cat)
|
|
|
-code=$(printf '%s' "$email" | grep -oP 'Extranet code: \K[0-9]{6}' | head -1)
|
|
|
-
|
|
|
-if [[ -z "$code" ]]; then
|
|
|
- echo "sms_code_filter: no Extranet code found in message" >&2
|
|
|
- exit 0 # exit 0 so Sieve doesn't treat it as a filter failure
|
|
|
-fi
|
|
|
-
|
|
|
-curl -fsS \
|
|
|
- -X POST \
|
|
|
- -H "Content-Type: application/json" \
|
|
|
- -H "X-SMS-Secret: ${SECRET}" \
|
|
|
- -d "{\"code\": \"${code}\"}" \
|
|
|
- "${API_URL%/}/sms/code"
|