Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
api: Fix encoding of strings in hotspot endpoint.
Gaurav Pandeyd6cf1ef27b17
diff --git a/static/js/hotspots.js b/static/js/hotspots.jsindex 32f53e9ab54..6c24f3fb77d 100644--- a/static/js/hotspots.js+++ b/static/js/hotspots.js@@ -71,7 +71,7 @@ const WHALE = "/static/images/hotspots/whale.svg";export function post_hotspot_as_read(hotspot_name) {channel.post({url: "/json/users/me/hotspots",- data: {hotspot: JSON.stringify(hotspot_name)},+ data: {hotspot: hotspot_name},error(err) {blueslip.error(err.responseText);},diff --git a/zerver/tests/test_hotspots.py b/zerver/tests/test_hotspots.pyindex a46a6234364..747bdc12d9d 100644--- a/zerver/tests/test_hotspots.py+++ b/zerver/tests/test_hotspots.py@@ -1,5 +1,3 @@-import orjson-from zerver.lib.actions import do_create_user, do_mark_hotspot_as_readfrom zerver.lib.hotspots import ALL_HOTSPOTS, INTRO_HOTSPOTS, get_next_hotspotsfrom zerver.lib.test_classes import ZulipTestCase@@ -56,18 +54,14 @@ class TestHotspots(ZulipTestCase):def test_hotspots_url_endpoint(self) -> None:user = self.example_user("hamlet")self.login_user(user)- result = self.client_post(- "/json/users/me/hotspots", {"hotspot": orjson.dumps("intro_reply").decode()}- )+ result = self.client_post("/json/users/me/hotspots", {"hotspot": "intro_reply"})self.assert_json_success(result)self.assertEqual(list(UserHotspot.objects.filter(user=user).values_list("hotspot", flat=True)),["intro_reply"],)- result = self.client_post(- "/json/users/me/hotspots", {"hotspot": orjson.dumps("invalid").decode()}- )+ result = self.client_post("/json/users/me/hotspots", {"hotspot": "invalid"})self.assert_json_error(result, "Unknown hotspot: invalid")self.assertEqual(list(UserHotspot.objects.filter(user=user).values_list("hotspot", flat=True)),diff --git a/zerver/views/hotspots.py b/zerver/views/hotspots.pyindex 6eb68ecf43b..fdab56f4179 100644--- a/zerver/views/hotspots.py+++ b/zerver/views/hotspots.py@@ -6,14 +6,13 @@ from zerver.lib.actions import do_mark_hotspot_as_readfrom zerver.lib.hotspots import ALL_HOTSPOTSfrom zerver.lib.request import REQ, has_request_variablesfrom zerver.lib.response import json_error, json_success-from zerver.lib.validator import check_stringfrom zerver.models import UserProfile@human_users_only@has_request_variablesdef mark_hotspot_as_read(- request: HttpRequest, user: UserProfile, hotspot: str = REQ(json_validator=check_string)+ request: HttpRequest, user: UserProfile, hotspot: str = REQ()) -> HttpResponse:if hotspot not in ALL_HOTSPOTS:return json_error(_("Unknown hotspot: {}").format(hotspot))