diff --git a/scripts/signal-push.py b/scripts/signal-push.py index 5de8d6d..e61723d 100755 --- a/scripts/signal-push.py +++ b/scripts/signal-push.py @@ -96,6 +96,17 @@ def main() -> int: if body.get("status") == "pending_approval": print(f"signal-push: send queued for approval (id={body.get('request_id', '?')})") approval_url = body.get("approval_url", "") + # The gateway returns an absolute URL only when SEND_APPROVAL_BASE_URL + # is set on its side; otherwise it hands back a bare relative path. + # Absolutize it here against SEND_APPROVAL_BASE_URL, falling back to + # CONVERSATION_BASE_URL (present in this container), so the printed + # link is always complete and never has to be assembled by hand. + # Mirrors email_client.approval_url(). + if approval_url.startswith("/"): + base = (os.environ.get("SEND_APPROVAL_BASE_URL") + or os.environ.get("CONVERSATION_BASE_URL", "")).rstrip("/") + if base: + approval_url = base + approval_url if approval_url: print(f"signal-push: approve or deny at {approval_url}") note = body.get("note", "") diff --git a/scripts/telegram-push.py b/scripts/telegram-push.py index 87cfdca..5ab9726 100755 --- a/scripts/telegram-push.py +++ b/scripts/telegram-push.py @@ -88,6 +88,17 @@ def main() -> int: if body.get("status") == "pending_approval": print(f"telegram-push: send queued for approval (id={body.get('request_id', '?')})") approval_url = body.get("approval_url", "") + # The gateway returns an absolute URL only when SEND_APPROVAL_BASE_URL + # is set on its side; otherwise it hands back a bare relative path. + # Absolutize it here against SEND_APPROVAL_BASE_URL, falling back to + # CONVERSATION_BASE_URL (present in this container), so the printed + # link is always complete and never has to be assembled by hand. + # Mirrors email_client.approval_url(). + if approval_url.startswith("/"): + base = (os.environ.get("SEND_APPROVAL_BASE_URL") + or os.environ.get("CONVERSATION_BASE_URL", "")).rstrip("/") + if base: + approval_url = base + approval_url if approval_url: print(f"telegram-push: approve or deny at {approval_url}") note = body.get("note", "") diff --git a/scripts/whatsapp-push.py b/scripts/whatsapp-push.py index 3405adf..346a56a 100755 --- a/scripts/whatsapp-push.py +++ b/scripts/whatsapp-push.py @@ -97,6 +97,17 @@ def main() -> int: if body.get("status") == "pending_approval": print(f"whatsapp-push: send queued for approval (id={body.get('request_id', '?')})") approval_url = body.get("approval_url", "") + # The gateway returns an absolute URL only when SEND_APPROVAL_BASE_URL + # is set on its side; otherwise it hands back a bare relative path. + # Absolutize it here against SEND_APPROVAL_BASE_URL, falling back to + # CONVERSATION_BASE_URL (present in this container), so the printed + # link is always complete and never has to be assembled by hand. + # Mirrors email_client.approval_url(). + if approval_url.startswith("/"): + base = (os.environ.get("SEND_APPROVAL_BASE_URL") + or os.environ.get("CONVERSATION_BASE_URL", "")).rstrip("/") + if base: + approval_url = base + approval_url if approval_url: print(f"whatsapp-push: approve or deny at {approval_url}") note = body.get("note", "")