messaging
Framework-agnostic messaging primitives. This package is the primary import
path for the former codex_platform.notifications API.
messaging
Framework-agnostic messaging primitives for codex-platform.
Classes
AudienceBuilder
Bases: Protocol
Materializes campaign recipients from a host-defined filter.
Source code in src/codex_platform/messaging/audience.py
Functions
count(audience_filter)
CampaignBatchDTO
Bases: BaseDTO
One campaign batch payload for the worker callback contract.
Source code in src/codex_platform/messaging/campaigns/dto.py
Functions
validate_rendering_mode()
Require exactly one campaign rendering mode.
Source code in src/codex_platform/messaging/campaigns/dto.py
CampaignDispatcher
Bases: Protocol
Enqueues campaign batches for worker-side delivery.
Source code in src/codex_platform/messaging/campaigns/protocols.py
CampaignRecipientDraft
Bases: BaseDTO
Recipient data needed by a campaign batch worker.
Source code in src/codex_platform/messaging/campaigns/dto.py
NotificationChannel
Bases: StrEnum
Supported notification delivery channel identifiers.
Source code in src/codex_platform/messaging/channels.py
AsyncEmailClient
Async SMTP email sender.
Source code in src/codex_platform/messaging/clients/smtp.py
Functions
is_available()
Returns True if the client is configured with a non-localhost host.
send(to, subject, html_content, text_content, headers=None, timeout=15)
async
Send email via SMTP.
Source code in src/codex_platform/messaging/clients/smtp.py
ArqNotificationAdapter
Bases: NotificationAdapter
Notification adapter that enqueues tasks into an ARQ/Redis queue.
Source code in src/codex_platform/messaging/delivery/arq.py
Functions
enqueue(task_name, payload)
Sync enqueue wrapper. Prefer enqueue_async in async contexts.
Source code in src/codex_platform/messaging/delivery/arq.py
enqueue_async(task_name, payload)
async
Enqueue a notification task into the ARQ queue.
Source code in src/codex_platform/messaging/delivery/arq.py
DirectNotificationAdapter
Bases: NotificationAdapter
Adapter for synchronous in-process notification delivery.
Source code in src/codex_platform/messaging/delivery/direct.py
Functions
enqueue(_task_name, payload)
Deliver a notification synchronously via the orchestrator pipeline.
Source code in src/codex_platform/messaging/delivery/direct.py
NotificationAdapter
Bases: Protocol
Contract for notification delivery transport.
Source code in src/codex_platform/messaging/delivery/base.py
NotificationPayloadDTO
Bases: BaseDTO
Base notification payload: identification and routing only.
Source code in src/codex_platform/messaging/dto.py
NotificationRecipient
RenderedNotificationDTO
Bases: NotificationPayloadDTO
Mode 2: pre-rendered HTML passed directly to the worker.
Source code in src/codex_platform/messaging/dto.py
TemplateNotificationDTO
Bases: NotificationPayloadDTO
Mode 1: worker fetches context from Redis and renders the template.
Source code in src/codex_platform/messaging/dto.py
ThreadHeadersDTO
Bases: BaseDTO
RFC 5322 threading headers attached to outbound email notifications.
Source code in src/codex_platform/messaging/dto.py
ContentCacheAdapter
Bases: Protocol
Adapter for caching email/notification content.
Source code in src/codex_platform/messaging/interfaces.py
Functions
get_cached_value(key)
ContentProvider
Bases: Protocol
Provides translated template text by key.
Source code in src/codex_platform/messaging/interfaces.py
BaseDeliveryOrchestrator
Tries channels in order and stops on the first successful delivery.
Source code in src/codex_platform/messaging/orchestrator.py
Functions
deliver(payload)
async
Deliver a notification payload through available channels.
Source code in src/codex_platform/messaging/orchestrator.py
DeliveryChannel
Bases: Protocol
Contract for a single delivery method.
Source code in src/codex_platform/messaging/orchestrator.py
Functions
send(to, subject, html_content, text_content, headers=None)
async
Attempt delivery. Return True on success, False on logical failure.
Source code in src/codex_platform/messaging/orchestrator.py
ChannelRegistry
Registry for config-driven delivery channel factories.
Source code in src/codex_platform/messaging/registry.py
Functions
register(name, factory)
Register a channel factory.
Source code in src/codex_platform/messaging/registry.py
build_channels(config)
Build available channels from registered factories.
Source code in src/codex_platform/messaging/registry.py
TemplateRenderer
Jinja2 HTML template renderer.
Source code in src/codex_platform/messaging/renderer.py
Functions
render(template_name, context)
Render a template with the given context.
Source code in src/codex_platform/messaging/renderer.py
Functions
resolve_template_path(template_name, prefix_map=None)
Map a template key such as bk_confirmation to a template path.
Source code in src/codex_platform/messaging/renderer.py
build_message_id(*, domain)
Build a host-scoped RFC 5322 Message-ID.
Source code in src/codex_platform/messaging/threading.py
build_thread_key()
Build an opaque thread key safe to use in email headers and URLs.
parse_references(header_value)
Parse a References header into individual Message-ID values.
render_email_headers(dto)
Render thread DTO fields into outbound email headers.