mirror of https://github.com/zulip/zulip.git
push_notifs: Require ios_app_id on register at bouncer, too.
We'll need this information in order to properly direct APNs
notifications. Happily, the Zulip server always sends it when
registering an APNs token; and it appears it always has done so
since the commit:
cddee49e7
Add support infrastructure for push notification bouncer service.
back in 2016. So there's no compatibility issue from requiring it.
This commit is contained in:
parent
9c2d53bcef
commit
1b2178f558
|
@ -27,6 +27,12 @@ format used by the Zulip server that they are interacting with.
|
|||
Previously it defaulted to the server setting `ZULIP_IOS_APP_ID`,
|
||||
defaulting to "org.zulip.Zulip".
|
||||
|
||||
* `POST /remotes/server/register`: The `ios_app_id` parameter is now
|
||||
required when `kind` is 1, i.e. when registering an APNs token.
|
||||
Previously it was ignored, and the push bouncer effectively
|
||||
assumed its value was the server setting `APNS_TOPIC`,
|
||||
defaulting to "org.zulip.Zulip".
|
||||
|
||||
**Feature level 222**
|
||||
|
||||
* [`GET /events`](/api/get-events): When a user is deactivated or
|
||||
|
|
|
@ -500,6 +500,31 @@ class PushBouncerNotificationTest(BouncerTestCase):
|
|||
401,
|
||||
)
|
||||
|
||||
def test_register_require_ios_app_id(self) -> None:
|
||||
endpoint = "/api/v1/remotes/push/register"
|
||||
args = {"user_id": 11, "token": "1122"}
|
||||
|
||||
result = self.uuid_post(
|
||||
self.server_uuid,
|
||||
endpoint,
|
||||
{**args, "token_kind": PushDeviceToken.APNS},
|
||||
)
|
||||
self.assert_json_error(result, "Missing ios_app_id")
|
||||
|
||||
result = self.uuid_post(
|
||||
self.server_uuid,
|
||||
endpoint,
|
||||
{**args, "token_kind": PushDeviceToken.APNS, "ios_app_id": "example.app"},
|
||||
)
|
||||
self.assert_json_success(result)
|
||||
|
||||
result = self.uuid_post(
|
||||
self.server_uuid,
|
||||
endpoint,
|
||||
{**args, "token_kind": PushDeviceToken.GCM},
|
||||
)
|
||||
self.assert_json_success(result)
|
||||
|
||||
def test_register_device_deduplication(self) -> None:
|
||||
hamlet = self.example_user("hamlet")
|
||||
token = "111222"
|
||||
|
|
|
@ -165,6 +165,8 @@ def register_remote_push_device(
|
|||
ios_app_id: Optional[str] = REQ(default=None),
|
||||
) -> HttpResponse:
|
||||
validate_bouncer_token_request(token, token_kind)
|
||||
if token_kind == RemotePushDeviceToken.APNS and ios_app_id is None:
|
||||
raise JsonableError(_("Missing ios_app_id"))
|
||||
|
||||
if user_id is None and user_uuid is None:
|
||||
raise JsonableError(_("Missing user_id or user_uuid"))
|
||||
|
|
Loading…
Reference in New Issue