From ee5ff0fa416cb959c73583fa1c3fe3eee08ff069 Mon Sep 17 00:00:00 2001 From: benya Date: Mon, 6 Apr 2026 01:02:07 +0300 Subject: [PATCH] fix: sanitize fcm data payload keys for android - avoid reserved FCM key names like message_type - send push metadata in camelCase keys already supported by Android --- app/notifications/tasks.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/notifications/tasks.py b/app/notifications/tasks.py index 381811b..f142e3c 100644 --- a/app/notifications/tasks.py +++ b/app/notifications/tasks.py @@ -81,10 +81,26 @@ def _send_fcm_to_user(user_id: int, title: str, body: str, data: dict[str, Any]) return string_data = { - **{str(key): str(value) for key, value in data.items()}, "title": title, "body": body, } + for key, value in data.items(): + normalized_key = str(key) + if normalized_key == "chat_id": + normalized_key = "chatId" + elif normalized_key == "message_id": + normalized_key = "messageId" + elif normalized_key == "sender_id": + normalized_key = "senderId" + elif normalized_key == "message_type": + normalized_key = "messageType" + elif normalized_key == "preview_image_url": + normalized_key = "previewImageUrl" + elif normalized_key == "sender_name": + normalized_key = "senderName" + elif normalized_key == "text_preview": + normalized_key = "textPreview" + string_data[normalized_key] = str(value) for platform, token in tokens: webpush = None notification = None