## Summary Closes #9. - Campaign composer auto-inserts a tracked homepage link (`utm_source=monica`, `utm_medium` = channel, `utm_campaign` = slug of the name) for email, SMS, and postcard QR — no manual UTM paste. - When `SHORTENER_BASE_URL` + `SHORTENER_API_TOKEN` are set, the app mints that long HTTPS URL via `POST /api/links/` on the shortener **API host** and puts the returned `piha.li` / `beta.piha.li` short URL in SMS, email hrefs, and QR codes. Empty env (local) falls back to the long UTM URL. - Live composer resolves shorts through a portal JSON endpoint (login + CSRF). Browser never calls the shortener. ## Secrets (control node, not git) **monica_site** (`~/Documents/secrets/monica_site/`): ``` # prod SHORTENER_BASE_URL=https://shortener.aimloperations.com SHORTENER_API_TOKEN=monica:<secret> # beta SHORTENER_BASE_URL=https://shortener-beta.aimloperations.com SHORTENER_API_TOKEN=monica:<beta-secret> ``` **url_shortening_service** (same secret, named token): ``` SHORTENER_API_TOKENS=monica:<secret> SHORT_ALLOWED_HOSTS=mkdrealtor.com,aimloperations.com ``` Prod public short host: `piha.li`. Beta: `beta.piha.li`. Generate with `python -c "import secrets; print(secrets.token_urlsafe(32))"`. Template port: westfarn/web_django_template#3 ## Test plan - [ ] `cd site && uv run python manage.py test messaging.tests.CampaignUtmLinkTests` - [ ] Composer: type a campaign name — email gets an HTML link, SMS gets a URL, postcard shows a QR - [ ] With shortener env set: SMS/QR show `piha.li` (or `beta.piha.li`); without it, long UTM URL still works - [ ] Copy/download QR into postcard designer - [ ] Secret files have `SHORTENER_*` on both caller and operator sides before beta/prod deploy Reviewed-on: #10
62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
from django.urls import path
|
|
|
|
from messaging import views
|
|
|
|
app_name = "messaging"
|
|
|
|
urlpatterns = [
|
|
path("campaigns/", views.campaign_list, name="campaign_list"),
|
|
path(
|
|
"campaigns/short-link/",
|
|
views.campaign_short_link,
|
|
name="campaign_short_link",
|
|
),
|
|
path("campaigns/<uuid:pk>/", views.campaign_detail, name="campaign_detail"),
|
|
path(
|
|
"campaigns/<uuid:pk>/status.json",
|
|
views.campaign_status_json,
|
|
name="campaign_status_json",
|
|
),
|
|
path("campaigns/<uuid:pk>/send/", views.campaign_send, name="campaign_send"),
|
|
path(
|
|
"campaigns/<uuid:pk>/test-send/",
|
|
views.campaign_test_send,
|
|
name="campaign_test_send",
|
|
),
|
|
path(
|
|
"campaigns/<uuid:pk>/messages/<uuid:message_id>/remove/",
|
|
views.campaign_message_remove,
|
|
name="campaign_message_remove",
|
|
),
|
|
path(
|
|
"campaigns/upload-image/",
|
|
views.campaign_image_upload,
|
|
name="campaign_image_upload",
|
|
),
|
|
path(
|
|
"files/<uuid:pk>/",
|
|
views.stored_file,
|
|
name="stored_file",
|
|
),
|
|
path("postcard/", views.postcard_designer, name="postcard_designer"),
|
|
path(
|
|
"postcard/create/",
|
|
views.postcard_design_create,
|
|
name="postcard_design_create",
|
|
),
|
|
path(
|
|
"postcard/save/",
|
|
views.postcard_design_save,
|
|
name="postcard_design_save",
|
|
),
|
|
path("webhooks/smtp2go/", views.smtp2go_webhook, name="smtp2go_webhook"),
|
|
# Legacy aliases — same unified SMTP2GO handler.
|
|
path("webhooks/sms/", views.sms_webhook, name="sms_webhook"),
|
|
path("webhooks/email/", views.email_webhook, name="email_webhook"),
|
|
path(
|
|
"webhooks/postcard/",
|
|
views.postcard_webhook,
|
|
name="postcard_webhook",
|
|
),
|
|
]
|