glue: fix portal smtp host and mail sync export

This commit is contained in:
Brad Stein 2026-01-19 00:35:40 -03:00
parent 73c829c81f
commit e18e698fb9
3 changed files with 8 additions and 8 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ __pycache__/
*.py[cod] *.py[cod]
.pytest_cache .pytest_cache
.venv .venv
tmp/

View File

@ -34,7 +34,7 @@ spec:
export PORTAL_E2E_CLIENT_SECRET="{{ .Data.data.client_secret }}" export PORTAL_E2E_CLIENT_SECRET="{{ .Data.data.client_secret }}"
{{ end }} {{ end }}
{{ with secret "kv/data/atlas/shared/postmark-relay" }} {{ with secret "kv/data/atlas/shared/postmark-relay" }}
export SMTP_HOST="mail.bstein.dev" export SMTP_HOST="smtp.postmarkapp.com"
export SMTP_PORT="587" export SMTP_PORT="587"
export SMTP_STARTTLS="true" export SMTP_STARTTLS="true"
export SMTP_USE_TLS="false" export SMTP_USE_TLS="false"

View File

@ -54,17 +54,16 @@ list_mail_accounts() {
local export_out local export_out
# Nextcloud Mail does not provide a list command; export is safe (does not print passwords). # Nextcloud Mail does not provide a list command; export is safe (does not print passwords).
if ! export_out=$(/usr/sbin/runuser -u www-data -- php occ mail:account:export --output json "${user_id}"); then if ! export_out=$(/usr/sbin/runuser -u www-data -- php occ mail:account:export "${user_id}"); then
echo "WARN: unable to export mail accounts for ${user_id}; skipping sync for safety" >&2 echo "WARN: unable to export mail accounts for ${user_id}; skipping sync for safety" >&2
return 1 return 1
fi fi
if ! jq -e 'type == "array"' >/dev/null 2>&1 <<<"${export_out}"; then awk -v OFS='\t' '
echo "WARN: unexpected mail export output for ${user_id}; skipping sync for safety" >&2 BEGIN { IGNORECASE=1; id="" }
return 1 $1 == "Account" { id=$2; sub(":", "", id); next }
fi $1 == "-" && tolower($2) ~ /^e-?mail:$/ { if (id) print id, $3 }
' <<<"${export_out}" | sort -u
jq -r '.[] | "\(.id)\t\(.email)"' <<<"${export_out}" | sort -u
} }
token=$( token=$(