diff --git a/notifications_routing/router.py b/notifications_routing/router.py index 77a64e40b363dc86e605b6896a1633badfdd10f8..e6a06965d4bbccaeb7d733249943beb8b470ab56 100644 --- a/notifications_routing/router.py +++ b/notifications_routing/router.py @@ -68,7 +68,7 @@ class Router(megabus.Listener): category_name = ( channel[str(InputMessageKeys.CATEGORY)][str(InputMessageKeys.NAME)] - if InputMessageKeys.CATEGORY in channel + if str(InputMessageKeys.CATEGORY) in channel else None ) diff --git a/notifications_routing/utils.py b/notifications_routing/utils.py index 9405a7459eb3f1890f3075749f8a5224a5a7fc64..813666a2ec4a5bd96f3729451804d49bbb85a703 100644 --- a/notifications_routing/utils.py +++ b/notifications_routing/utils.py @@ -20,7 +20,7 @@ class InputMessageKeys(StrEnum): TARGET = "target" ID = "id" NAME = "name" - CATEGORY = "category_name" + CATEGORY = "category" SLUG = "slug" PRIORITY = "priority" SENT_AT = "sentAt" @@ -85,11 +85,9 @@ def convert_notification_email_to_json_string(message, email): "priority": message[OutputMessageKeys.PRIORITY], "notification_id": message[OutputMessageKeys.ID], "created_at": message[OutputMessageKeys.CREATED_TIMESTAMP], + "category_name": message[OutputMessageKeys.CHANNEL_CATEGORY], } - if str(OutputMessageKeys.CHANNEL_CATEGORY) in message: - notif["category_name"] = message[OutputMessageKeys.CHANNEL_CATEGORY] - return json.dumps(notif)