Template
Add campaign UTM links and piha.li shortener as a core helper.
Keep mint/UTM in always-on core so email_sms and directmail stay optional, and brand utm_source from SITE_NAME (or UTM_SOURCE) instead of a hardcoded client name. Closes #3
This commit is contained in:
@@ -23,6 +23,7 @@ from contacts.consent import ( # noqa: F401 — re-export for tests + providers
|
||||
unsubscribe_all,
|
||||
)
|
||||
from contacts.models import Channel, Contact
|
||||
from core.campaign_utm import ensure_campaign_utm_link
|
||||
from core.scheduling import parse_scheduled_for
|
||||
from email_sms.models import Campaign, Message, MessageTemplate
|
||||
|
||||
@@ -108,6 +109,17 @@ def create_campaign_draft(
|
||||
created_by=created_by,
|
||||
template=template,
|
||||
)
|
||||
if channel in (Channel.EMAIL, Channel.SMS):
|
||||
body = ensure_campaign_utm_link(
|
||||
body,
|
||||
name=name,
|
||||
medium=channel,
|
||||
html=(channel == Channel.EMAIL),
|
||||
campaign_id=campaign.pk,
|
||||
)
|
||||
if body != campaign.body_override:
|
||||
campaign.body_override = body
|
||||
campaign.save(update_fields=["body_override", "updated_at"])
|
||||
contacts = list(opted_in_contacts(channel))
|
||||
Message.objects.bulk_create(
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user