diff --git a/greg/management/commands/start_notification_publisher.py b/greg/management/commands/start_notification_publisher.py index c7257c948ae2ad522055f326539ddb97e2fb817c..2f8f10660b887f3bec5ed16728d4bfa557e3c93d 100644 --- a/greg/management/commands/start_notification_publisher.py +++ b/greg/management/commands/start_notification_publisher.py @@ -2,6 +2,7 @@ import json import logging import signal import sys +from typing import Union import daemon import lockfile @@ -60,14 +61,17 @@ def create_cloud_event_payload(n: Notification) -> str: """ object_type = camel_to_snake(n.object_type) - return json.dumps( - { - "id": str(n.id), - "source": f"urn:greg:{settings.INSTANCE_NAME}:{object_type}:{n.identifier}", - "specversion": "1.0", - "type": generate_event_type(n), + content: dict[str, Union[str, dict[str, str]]] = { + "id": str(n.id), + "source": f"urn:greg:{settings.INSTANCE_NAME}:{object_type}:{n.identifier}", + "specversion": "1.0", + "type": generate_event_type(n), + } + if n.object_type in ("Role", "Consent", "Identity"): + content["data"] = { + "person_id": n.meta.get("person_id"), } - ) + return json.dumps(content) def handle_one_notification(notification: Notification, pcm: PCM, exchange: str):