From a12006d86f23a2fbfb566271e3bda3c68ac43ab6 Mon Sep 17 00:00:00 2001 From: Ashish Date: Sun, 3 Apr 2016 11:28:06 +0530 Subject: [PATCH] Replace /json/update_active_status with REST style route. --- static/js/activity.js | 2 +- tools/deprecated/stress-test/stress-test.coffee | 2 +- zerver/decorator.py | 2 +- zerver/tests.py | 16 ++++++++-------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/static/js/activity.js b/static/js/activity.js index 0e37bc6d4b..9840e60057 100644 --- a/static/js/activity.js +++ b/static/js/activity.js @@ -353,7 +353,7 @@ exports._status_from_timestamp = status_from_timestamp; function focus_ping() { channel.post({ - url: '/json/update_active_status', + url: '/json/users/me/presence', data: {status: (exports.has_focus) ? exports.ACTIVE : exports.IDLE, new_user_input: exports.new_user_input}, idempotent: true, diff --git a/tools/deprecated/stress-test/stress-test.coffee b/tools/deprecated/stress-test/stress-test.coffee index ef024ab50a..22052972b8 100644 --- a/tools/deprecated/stress-test/stress-test.coffee +++ b/tools/deprecated/stress-test/stress-test.coffee @@ -75,7 +75,7 @@ class ZulipSession extends Session message_latency.update(+new Date() - parseInt(m[1], 10)) update_active_status: -> - @post "/json/update_active_status", {status: "active"}, update_status_time.cbTimer() + @post "/json/users/me/presence", {status: "active"}, update_status_time.cbTimer() send_stream_message: (stream, subject, content) -> @post '/json/messages', { diff --git a/zerver/decorator.py b/zerver/decorator.py index ad04bda21e..d741d41b71 100644 --- a/zerver/decorator.py +++ b/zerver/decorator.py @@ -55,7 +55,7 @@ def asynchronous(method): def update_user_activity(request, user_profile): # update_active_status also pushes to rabbitmq, and it seems # redundant to log that here as well. - if request.META["PATH_INFO"] == '/json/update_active_status': + if request.META["PATH_INFO"] == '/json/users/me/presence': return if hasattr(request, '_query'): diff --git a/zerver/tests.py b/zerver/tests.py index f5a88e8946..9d6d02e6fd 100644 --- a/zerver/tests.py +++ b/zerver/tests.py @@ -1141,7 +1141,7 @@ class UserPresenceTests(AuthedTestCase): self.assertEqual(list(json['presences'].keys()), ['hamlet@zulip.com']) return json['presences'][email][client]['timestamp'] - result = self.client.post("/json/update_active_status", {'status': 'idle'}) + result = self.client.post("/json/users/me/presence", {'status': 'idle'}) test_result(result) result = self.client.post("/json/get_active_statuses", {}) @@ -1149,7 +1149,7 @@ class UserPresenceTests(AuthedTestCase): email = "othello@zulip.com" self.login(email) - self.client.post("/json/update_active_status", {'status': 'idle'}) + self.client.post("/json/users/me/presence", {'status': 'idle'}) result = self.client.post("/json/get_active_statuses", {}) self.assert_json_success(result) json = ujson.loads(result.content) @@ -1163,7 +1163,7 @@ class UserPresenceTests(AuthedTestCase): self.login("hamlet@zulip.com") client = 'website' - self.client.post("/json/update_active_status", {'status': 'idle'}) + self.client.post("/json/users/me/presence", {'status': 'idle'}) result = self.client.post("/json/get_active_statuses", {}) self.assert_json_success(result) @@ -1172,14 +1172,14 @@ class UserPresenceTests(AuthedTestCase): email = "othello@zulip.com" self.login("othello@zulip.com") - self.client.post("/json/update_active_status", {'status': 'idle'}) + self.client.post("/json/users/me/presence", {'status': 'idle'}) result = self.client.post("/json/get_active_statuses", {}) self.assert_json_success(result) json = ujson.loads(result.content) self.assertEqual(json['presences'][email][client]['status'], 'idle') self.assertEqual(json['presences']['hamlet@zulip.com'][client]['status'], 'idle') - self.client.post("/json/update_active_status", {'status': 'active'}) + self.client.post("/json/users/me/presence", {'status': 'active'}) result = self.client.post("/json/get_active_statuses", {}) self.assert_json_success(result) json = ujson.loads(result.content) @@ -1189,19 +1189,19 @@ class UserPresenceTests(AuthedTestCase): def test_no_mit(self): # MIT never gets a list of users self.login("espuser@mit.edu") - result = self.client.post("/json/update_active_status", {'status': 'idle'}) + result = self.client.post("/json/users/me/presence", {'status': 'idle'}) self.assert_json_success(result) json = ujson.loads(result.content) self.assertEqual(json['presences'], {}) def test_same_realm(self): self.login("espuser@mit.edu") - self.client.post("/json/update_active_status", {'status': 'idle'}) + self.client.post("/json/users/me/presence", {'status': 'idle'}) result = self.client.post("/accounts/logout/") # Ensure we don't see hamlet@zulip.com information leakage self.login("hamlet@zulip.com") - result = self.client.post("/json/update_active_status", {'status': 'idle'}) + result = self.client.post("/json/users/me/presence", {'status': 'idle'}) self.assert_json_success(result) json = ujson.loads(result.content) self.assertEqual(json['presences']["hamlet@zulip.com"]["website"]['status'], 'idle')