From 0e98e5500b7e8712872997e0bd7092bf458dc5cb Mon Sep 17 00:00:00 2001 From: Charlie Calendre <57274151+c-cal@users.noreply.github.com> Date: Thu, 21 Mar 2024 18:47:00 +0100 Subject: [PATCH] Check if `data["content"]` is a dict before using it as a dict (#362) --- changelog.d/362.bugfix | 1 + sygnal/gcmpushkin.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog.d/362.bugfix diff --git a/changelog.d/362.bugfix b/changelog.d/362.bugfix new file mode 100644 index 00000000..a3d3a394 --- /dev/null +++ b/changelog.d/362.bugfix @@ -0,0 +1 @@ +Fix a bug causing Sygnal to fail when processing notifications without a `content` dict, when those notifications were destined for GCM. Contributed by @c-cal. diff --git a/sygnal/gcmpushkin.py b/sygnal/gcmpushkin.py index 1177c0aa..621c2fd7 100644 --- a/sygnal/gcmpushkin.py +++ b/sygnal/gcmpushkin.py @@ -669,7 +669,7 @@ def _build_data( data[attr] = data[attr][0:MAX_BYTES_PER_FIELD] if api_version is APIVersion.V1: - if "content" in data: + if isinstance(data.get("content"), dict): for attr, value in data["content"].items(): if not isinstance(value, str): continue