Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

push_notifications: Include stream_id in the notification data.

Mateusz Manderac0f7158378c9
diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md
index 83a7424ee36..0362df9b4df 100644
--- a/templates/zerver/api/changelog.md
+++ b/templates/zerver/api/changelog.md
@@ -20,6 +20,12 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 5.0
+
+**Feature level 115**
+
+* Mobile push notifications about stream messages now include the
+ `stream_id` field.
+
**Feature level 114**
* [`GET /events`](/api/get-events): Added `rendering_only` field to
diff --git a/version.py b/version.py
index 18816eda0b4..71905ba4258 100644
--- a/version.py
+++ b/version.py
@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3"
# Changes should be accompanied by documentation explaining what the
# new level means in templates/zerver/api/changelog.md, as well as
# "**Changes**" entries in the endpoint's documentation in `zulip.yaml`.
-API_FEATURE_LEVEL = 114
+API_FEATURE_LEVEL = 115
# Bump the minor PROVISION_VERSION to indicate that folks should provision
# only when going from an old version of the code to a newer version. Bump
diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py
index c23764cd2ca..f08973a5643 100644
--- a/zerver/lib/push_notifications.py
+++ b/zerver/lib/push_notifications.py
@@ -714,6 +714,7 @@ def get_message_payload(
if message.recipient.type == Recipient.STREAM:
data["recipient_type"] = "stream"
data["stream"] = get_display_recipient(message.recipient)
+ data["stream_id"] = message.recipient.type_id
data["topic"] = message.topic_name()
elif message.recipient.type == Recipient.HUDDLE:
data["recipient_type"] = "private"
diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py
index 720752ce884..46c6e90719e 100644
--- a/zerver/tests/test_push_notifications.py
+++ b/zerver/tests/test_push_notifications.py
@@ -1717,6 +1717,7 @@ class TestGetAPNsPayload(PushNotificationTest):
"sender_email": self.sender.email,
"sender_id": self.sender.id,
"stream": get_display_recipient(message.recipient),
+ "stream_id": stream.id,
"topic": message.topic_name(),
"server": settings.EXTERNAL_HOST,
"realm_id": self.sender.realm.id,
@@ -1747,6 +1748,7 @@ class TestGetAPNsPayload(PushNotificationTest):
"sender_email": self.sender.email,
"sender_id": self.sender.id,
"stream": get_display_recipient(message.recipient),
+ "stream_id": stream.id,
"topic": message.topic_name(),
"server": settings.EXTERNAL_HOST,
"realm_id": self.sender.realm.id,
@@ -1780,6 +1782,7 @@ class TestGetAPNsPayload(PushNotificationTest):
"sender_email": self.sender.email,
"sender_id": self.sender.id,
"stream": get_display_recipient(message.recipient),
+ "stream_id": stream.id,
"topic": message.topic_name(),
"server": settings.EXTERNAL_HOST,
"realm_id": self.sender.realm.id,
@@ -1814,6 +1817,7 @@ class TestGetAPNsPayload(PushNotificationTest):
"sender_email": self.sender.email,
"sender_id": self.sender.id,
"stream": get_display_recipient(message.recipient),
+ "stream_id": stream.id,
"topic": message.topic_name(),
"server": settings.EXTERNAL_HOST,
"realm_id": self.sender.realm.id,
@@ -1901,6 +1905,7 @@ class TestGetGCMPayload(PushNotificationTest):
"sender_avatar_url": absolute_avatar_url(message.sender),
"recipient_type": "stream",
"stream": get_display_recipient(message.recipient),
+ "stream_id": stream.id,
"topic": message.topic_name(),
}
@@ -1995,6 +2000,7 @@ class TestGetGCMPayload(PushNotificationTest):
"recipient_type": "stream",
"topic": "Test topic",
"stream": "Denmark",
+ "stream_id": stream.id,
},
)
self.assertDictEqual(
@@ -2032,6 +2038,7 @@ class TestGetGCMPayload(PushNotificationTest):
"recipient_type": "stream",
"topic": "Test topic",
"stream": "Denmark",
+ "stream_id": stream.id,
},
)
self.assertDictEqual(