From 622e87208a6fe94f0a53ff8aba2b19f47ca61fd2 Mon Sep 17 00:00:00 2001 From: Nick Barrett Date: Thu, 16 Mar 2023 18:38:35 +0000 Subject: [PATCH] Fix FCM second retry sends When the first attempt succeeds for all but one pushkey the second attempt will end up populating both the `to` and `registration_ids` fields, which is rejected by FCM (400). --- sygnal/gcmpushkin.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sygnal/gcmpushkin.py b/sygnal/gcmpushkin.py index f725b51f..91a81811 100644 --- a/sygnal/gcmpushkin.py +++ b/sygnal/gcmpushkin.py @@ -371,10 +371,13 @@ async def _dispatch_notification_unlimited( body["priority"] = "normal" if n.prio == "low" else "high" for retry_number in range(0, MAX_TRIES): + # Should only ever be one of `to` or `registration_ids` fields if len(pushkeys) == 1: body["to"] = pushkeys[0] + body.pop("registration_ids", None) else: body["registration_ids"] = pushkeys + body.pop("to", None) log.info("Sending (attempt %i) => %r", retry_number, pushkeys)