Point SHORTENER_BASE_URL at piha.lc / beta.piha.li instead of a separate API host.
CI / test (pull_request) Successful in 21s

Closes #11.
This commit is contained in:
2026-08-30 19:25:03 -05:00
parent 2b3f10e784
commit fe54f4eca1
7 changed files with 18 additions and 18 deletions
+2 -2
View File
@@ -79,8 +79,8 @@ SOCIAL_TOKEN_ENCRYPTION_KEY=
OLLAMA_BASE_URL=http://10.0.0.128:11434
OLLAMA_MODEL=llama3.2
# URL shortener (piha.li). Empty locally = long UTM URLs in campaigns.
# Call the API host, never https://piha.li (that host only 302s).
# URL shortener (piha.lc). Empty locally = long UTM URLs in campaigns.
# Call the short host: POST /api/links/ (Bearer) and recipients GET /<code>.
SHORTENER_BASE_URL=
SHORTENER_API_TOKEN=
# Local shortener compose:
+3 -3
View File
@@ -88,10 +88,10 @@ OLLAMA_MODEL=llama3.2
OLLAMA_TIMEOUT_SECONDS=120
# URL shortener — mint short links for campaign SMS / email / postcard QR.
# POST /api/links/ on the API host. Recipients hit https://piha.li/<code>.
# POST /api/links/ on the same host phones hit. Recipients use https://piha.lc/<code>.
# Token must match SHORTENER_API_TOKENS on url_shortening_service (name:secret).
# Generate: python -c "import secrets; print(secrets.token_urlsafe(32))"
SHORTENER_BASE_URL=https://shortener.aimloperations.com
SHORTENER_BASE_URL=https://piha.lc
SHORTENER_API_TOKEN=monica:replace-me
# Nominatim address suggest (server-side proxy only; not called from browser)
@@ -130,5 +130,5 @@ GUNICORN_BIND=0.0.0.0:8000
# OLLAMA_BASE_URL=http://10.0.0.128:11434
# NOMINATIM_BASE_URL=http://10.0.0.128:8089
# NOMINATIM_COUNTRY_CODES=us
# SHORTENER_BASE_URL=https://shortener-beta.aimloperations.com
# SHORTENER_BASE_URL=https://beta.piha.li
# SHORTENER_API_TOKEN=monica:replace-with-a-different-token
+4 -4
View File
@@ -78,12 +78,12 @@ Campaign UTM short links (piha.li) need **both** sides:
| File | Vars |
|------|------|
| `monica_site_prod.env` | `SHORTENER_BASE_URL=https://shortener.aimloperations.com` · `SHORTENER_API_TOKEN=monica:<secret>` |
| `monica_site_beta.env` | `SHORTENER_BASE_URL=https://shortener-beta.aimloperations.com` · distinct `SHORTENER_API_TOKEN` |
| `url_shortening_service_prod.env` | `SHORTENER_API_TOKENS=monica:<same-secret>` · `SHORT_ALLOWED_HOSTS` includes `mkdrealtor.com` · `PUBLIC_SHORT_URL=https://piha.li` |
| `monica_site_prod.env` | `SHORTENER_BASE_URL=https://piha.lc` · `SHORTENER_API_TOKEN=monica:<secret>` |
| `monica_site_beta.env` | `SHORTENER_BASE_URL=https://beta.piha.li` · distinct `SHORTENER_API_TOKEN` |
| `url_shortening_service_prod.env` | `SHORTENER_API_TOKENS=monica:<same-secret>` · `SHORT_ALLOWED_HOSTS` includes `mkdrealtor.com` · `PUBLIC_SHORT_URL=https://piha.lc` |
| `url_shortening_service_beta.env` | matching beta token · `PUBLIC_SHORT_URL=https://beta.piha.li` |
Generate the secret with `python -c "import secrets; print(secrets.token_urlsafe(32))"`. Do not put it in git. Call the API host, never `piha.li`, to mint links.
Generate the secret with `python -c "import secrets; print(secrets.token_urlsafe(32))"`. Do not put it in git. Mint and redirects share the short host; Bearer is required on `/api/`.
## Deploy
+1 -1
View File
@@ -50,7 +50,7 @@ long HTTPS URL to `url_shortening_service` (`POST /api/links/`, Bearer
`monica:<secret>`) and puts `short_url` (`https://piha.li/<code>`) in SMS,
email hrefs, and postcard QR codes. Empty env → long UTM URL (local default).
Mint against the **API host**, not `piha.li`. See `.env.example` / `.env.prod.example`.
Mint against the short host (`https://piha.lc` / `https://beta.piha.li`). See `.env.example` / `.env.prod.example`.
SMS correlation uses `message_id` (SMS id), then `destination_number` phone
fallback. Do **not** treat webhook `id` as the SMS id.
+2 -2
View File
@@ -1,6 +1,6 @@
"""Server-to-server client for url_shortening_service (piha.li).
"""Server-to-server client for url_shortening_service (piha.lc).
Call the API host (`SHORTENER_BASE_URL`), never the public short domain.
Call SHORTENER_BASE_URL (https://piha.lc / https://beta.piha.li).
Auth: Authorization: Bearer <SHORTENER_API_TOKEN> (name:secret).
"""
+3 -3
View File
@@ -1598,7 +1598,7 @@ class CampaignUtmLinkTests(TestCase):
}
with self.settings(
PUBLIC_SITE_URL="https://mkdrealtor.com",
SHORTENER_BASE_URL="https://shortener.aimloperations.com",
SHORTENER_BASE_URL="https://piha.lc",
SHORTENER_API_TOKEN="monica:test-token",
):
with patch(
@@ -1630,7 +1630,7 @@ class CampaignUtmLinkTests(TestCase):
mock.text = '{"detail":"Unauthorized"}'
with self.settings(
PUBLIC_SITE_URL="https://mkdrealtor.com",
SHORTENER_BASE_URL="https://shortener.aimloperations.com",
SHORTENER_BASE_URL="https://piha.lc",
SHORTENER_API_TOKEN="monica:bad",
):
with patch("messaging.shortener.requests.post", return_value=mock):
@@ -1687,7 +1687,7 @@ class CampaignUtmLinkTests(TestCase):
url = reverse("messaging:campaign_short_link")
with self.settings(
PUBLIC_SITE_URL="https://mkdrealtor.com",
SHORTENER_BASE_URL="https://shortener.aimloperations.com",
SHORTENER_BASE_URL="https://piha.lc",
SHORTENER_API_TOKEN="monica:test-token",
):
with patch("messaging.shortener.requests.post", return_value=mock):
+3 -3
View File
@@ -332,9 +332,9 @@ NOMINATIM_USER_AGENT = env(
)
NOMINATIM_API_KEY = env("NOMINATIM_API_KEY", "")
# --- URL shortener (piha.li) ---
# Call the API host, never the public short domain. Empty = skip minting
# (composer falls back to the long UTM URL). Token format: name:secret.
# --- URL shortener (piha.lc) ---
# Same host as SMS links. Empty = skip minting (composer falls back to the
# long UTM URL). Token format: name:secret.
SHORTENER_BASE_URL = env("SHORTENER_BASE_URL", "")
SHORTENER_API_TOKEN = env("SHORTENER_API_TOKEN", "")
SHORTENER_TIMEOUT_SECONDS = int(env("SHORTENER_TIMEOUT_SECONDS", "10") or "10")