BloomERP

Create a custom inbox source

See the built-in reference for the definition fields and available built-ins.

Register a project event for system notifications

Reuse the system message resolver and handler. The event publisher supplies recipient IDs, message type, and message data.

python
from bloomerp.communication.builtins.in_app_notifications.inbox_sources import handle_system_message, resolve_system_message_folders
from bloomerp.communication.inbox_sources import InboxEventSource, InboxSourceRegistry
from bloomerp.communication.registry import INBOX_FOLDER_REGISTRY

review_event = InboxEventSource(
    id="example.review_requested",
    folder_qs_resolver=resolve_system_message_folders,
    handler=handle_system_message,
    run_async=False,
)
InboxSourceRegistry.register_source(
    review_event,
    folder_type=INBOX_FOLDER_REGISTRY.IN_APP_NOTIFICATIONS.id,
    origin="example.reviews",
)

Connect an inbox source to a project signal

Declare the signal and a stable receiver ID. When the app sends the signal, it supplies the same notification arguments as the event source.

python
from django.dispatch import Signal

from bloomerp.communication.builtins.in_app_notifications.inbox_sources import handle_system_message, resolve_system_message_folders
from bloomerp.communication.inbox_sources import InboxSignalSource, InboxSourceRegistry
from bloomerp.communication.registry import INBOX_FOLDER_REGISTRY

review_due = Signal()
review_due_source = InboxSignalSource(
    id="example.review_due",
    signal=review_due,
    dispatch_uid="example.review_due.receiver",
    folder_qs_resolver=resolve_system_message_folders,
    handler=handle_system_message,
    run_async=False,
)
InboxSourceRegistry.register_source(
    review_due_source,
    folder_type=INBOX_FOLDER_REGISTRY.IN_APP_NOTIFICATIONS.id,
    origin="example.reviews",
)