From 413dfa378a5c3634d4c3e137597f8d716afaabff Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Sun, 17 Nov 2024 17:16:34 +0100 Subject: [PATCH] new: [bluesky] add verify email capability through smtp relation --- bluesky/hooks/smtp_server-relation-joined | 61 +++++++++++++++++++++++ bluesky/metadata.yml | 10 +++- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100755 bluesky/hooks/smtp_server-relation-joined diff --git a/bluesky/hooks/smtp_server-relation-joined b/bluesky/hooks/smtp_server-relation-joined new file mode 100755 index 0000000..fc0b906 --- /dev/null +++ b/bluesky/hooks/smtp_server-relation-joined @@ -0,0 +1,61 @@ +#!/bin/bash + +set -e + +host=$(relation-get host) +port=$(relation-get port) +connection_security=$(relation-get connection-security) +auth_method=$(relation-get auth-method) + +opts=() +declare -A ENV +case "$connection_security" in + "none") + url+="smtp://" + opts+=( + "ignoreTLS=true" + "secure=false" + ) + ;; + "ssl/tls") + url+="smtps://" + ;; + *) + error "Unsupported connection security: $connection_security" + exit 1 + ;; +esac +case "$auth_method" in + "none") + : + ;; + "password") + login=$(relation-get login) || true + password=$(relation-get password) || true + url+="$login:$password@" + ;; + *) + error "Unsupported auth method: $auth_method" + exit 1 + ;; +esac + +url+="$host:$port/" + +first=1 +for opt in "${opts[@]}"; do + if [ $first -eq 1 ]; then + url+="?" + first=0 + else + url+="&" + fi + url+="$opt" +done + +config-add "\ +services: + $MASTER_BASE_SERVICE_NAME: + environment: + PDS_EMAIL_SMTP_URL: \"$url\" +" diff --git a/bluesky/metadata.yml b/bluesky/metadata.yml index cddd8fe..3edc7b7 100644 --- a/bluesky/metadata.yml +++ b/bluesky/metadata.yml @@ -2,8 +2,11 @@ docker-image: docker.0k.io/bluesky:0.4.67 ## from: ghcr.io/bluesky-social/pds:0 data-resources: - /var/lib/bluesky -default-options: +docker-compose: + environment: + PDS_EMAIL_FROM_ADDRESS: "no-reply@no-domain.org" +default-options: uses: web-proxy: #constraint: required | recommended | optional @@ -28,3 +31,8 @@ uses: ## - must start with a '/', will start from $SERVICE_DATASTORE #exclude-patterns: # - "/var/lib/odoo/sessions/" + smtp-server: + constraint: optional + auto: pair + solves: + mail: "verify email"