From 00647b6fa710582dcc804cfddb59014cfd9fd9ea Mon Sep 17 00:00:00 2001 From: Gaurav Pandey Date: Fri, 7 May 2021 00:44:16 +0530 Subject: [PATCH] api: Fix encoding of strings in video calls endpoint. This removes unnecessary json_validator for string parameters in the BigBlueButton video calls endpoints. Note that this breaks links to video meetings sent before the upgrade; there's not much we can do about that. Since this is the last commit in this series, we update the ZULIP_FEATURE_LEVEL for this batch of changes. Fixes part of #18035. --- templates/zerver/api/changelog.md | 15 +++++++++++++++ version.py | 2 +- zerver/tests/test_create_video_call.py | 14 +++++++------- zerver/views/video_calls.py | 12 ++++++------ 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md index b13b198e3a..0358680faa 100644 --- a/templates/zerver/api/changelog.md +++ b/templates/zerver/api/changelog.md @@ -10,6 +10,21 @@ below features are supported. ## Changes in Zulip 4.0 +**Feature level 63** + +* `PATCH /settings/notifications`: Removed unnecessary JSON-encoding of string + parameter `notification_sound`. +* `PATCH /settings/display`: Removed unnecessary JSON-encoding of string + parameter `default_language`. +* `POST /users/me/tutorial_status`: Removed unnecessary JSON-encoding of string + parameter `status`. +* `POST /realm/domains`: Removed unnecessary JSON-encoding of string + parameter `domain`. +* `PATCH /default_stream_groups/{user_id}`: Removed unnecessary JSON-encoding of string + parameters `new_group_name` and `new_description`. +* `POST /users/me/hotspots`: Removed unnecessary JSON-encoding of string + parameter `hotspot`. + **Feature level 62** * Added `moderators only` option for `wildcard_mention_policy`. diff --git a/version.py b/version.py index c345d177f8..8927f095ec 100644 --- a/version.py +++ b/version.py @@ -30,7 +30,7 @@ DESKTOP_WARNING_VERSION = "5.2.0" # # Changes should be accompanied by documentation explaining what the # new level means in templates/zerver/api/changelog.md. -API_FEATURE_LEVEL = 62 +API_FEATURE_LEVEL = 63 # 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/tests/test_create_video_call.py b/zerver/tests/test_create_video_call.py index a281fdb500..b5ba928895 100644 --- a/zerver/tests/test_create_video_call.py +++ b/zerver/tests/test_create_video_call.py @@ -176,8 +176,8 @@ class TestVideoCall(ZulipTestCase): self.assert_json_success(response) self.assertEqual( response.json()["url"], - "/calls/bigbluebutton/join?meeting_id=%22zulip-1%22&password=%22AAAAAAAAAA%22" - "&checksum=%22697939301a52d3a2f0b3c3338895c1a5ab528933%22", + "/calls/bigbluebutton/join?meeting_id=zulip-1&password=AAAAAAAAAA" + "&checksum=697939301a52d3a2f0b3c3338895c1a5ab528933", ) @responses.activate @@ -189,7 +189,7 @@ class TestVideoCall(ZulipTestCase): ) response = self.client_get( "/calls/bigbluebutton/join", - {"meeting_id": '"zulip-1"', "password": '"a"', "checksum": '"check"'}, + {"meeting_id": "zulip-1", "password": "a", "checksum": "check"}, ) self.assertEqual(response.status_code, 302) self.assertEqual(isinstance(response, HttpResponseRedirect), True) @@ -209,7 +209,7 @@ class TestVideoCall(ZulipTestCase): ) response = self.client_get( "/calls/bigbluebutton/join", - {"meeting_id": '"zulip-1"', "password": '"a"', "checksum": '"check"'}, + {"meeting_id": "zulip-1", "password": "a", "checksum": "check"}, ) self.assert_json_error(response, "Error authenticating to the Big Blue Button server.") @@ -224,7 +224,7 @@ class TestVideoCall(ZulipTestCase): ) response = self.client_get( "/calls/bigbluebutton/join", - {"meeting_id": '"zulip-1"', "password": '"a"', "checksum": '"check"'}, + {"meeting_id": "zulip-1", "password": "a", "checksum": "check"}, ) self.assert_json_error(response, "Error connecting to the Big Blue Button server.") @@ -238,7 +238,7 @@ class TestVideoCall(ZulipTestCase): ) response = self.client_get( "/calls/bigbluebutton/join", - {"meeting_id": '"zulip-1"', "password": '"a"', "checksum": '"check"'}, + {"meeting_id": "zulip-1", "password": "a", "checksum": "check"}, ) self.assert_json_error(response, "Big Blue Button server returned an unexpected error.") @@ -246,6 +246,6 @@ class TestVideoCall(ZulipTestCase): with self.settings(BIG_BLUE_BUTTON_SECRET=None, BIG_BLUE_BUTTON_URL=None): response = self.client_get( "/calls/bigbluebutton/join", - {"meeting_id": '"zulip-1"', "password": '"a"', "checksum": '"check"'}, + {"meeting_id": "zulip-1", "password": "a", "checksum": "check"}, ) self.assert_json_error(response, "Big Blue Button is not configured.") diff --git a/zerver/views/video_calls.py b/zerver/views/video_calls.py index 1dc7c5ede7..1b27a2976c 100644 --- a/zerver/views/video_calls.py +++ b/zerver/views/video_calls.py @@ -188,9 +188,9 @@ def get_bigbluebutton_url(request: HttpRequest, user_profile: UserProfile) -> Ht "/calls/bigbluebutton/join", urlencode( { - "meeting_id": '"' + id + '"', - "password": '"' + password + '"', - "checksum": '"' + checksum + '"', + "meeting_id": id, + "password": password, + "checksum": checksum, } ), ) @@ -207,9 +207,9 @@ def get_bigbluebutton_url(request: HttpRequest, user_profile: UserProfile) -> Ht @has_request_variables def join_bigbluebutton( request: HttpRequest, - meeting_id: str = REQ(json_validator=check_string), - password: str = REQ(json_validator=check_string), - checksum: str = REQ(json_validator=check_string), + meeting_id: str = REQ(), + password: str = REQ(), + checksum: str = REQ(), ) -> HttpResponse: if settings.BIG_BLUE_BUTTON_URL is None or settings.BIG_BLUE_BUTTON_SECRET is None: return json_error(_("Big Blue Button is not configured."))