Replace /json/update_active_status with REST style route.

This commit is contained in:
Ashish 2016-04-03 11:28:06 +05:30 committed by Tim Abbott
parent 6356584f84
commit a12006d86f
4 changed files with 11 additions and 11 deletions

View File

@ -353,7 +353,7 @@ exports._status_from_timestamp = status_from_timestamp;
function focus_ping() { function focus_ping() {
channel.post({ channel.post({
url: '/json/update_active_status', url: '/json/users/me/presence',
data: {status: (exports.has_focus) ? exports.ACTIVE : exports.IDLE, data: {status: (exports.has_focus) ? exports.ACTIVE : exports.IDLE,
new_user_input: exports.new_user_input}, new_user_input: exports.new_user_input},
idempotent: true, idempotent: true,

View File

@ -75,7 +75,7 @@ class ZulipSession extends Session
message_latency.update(+new Date() - parseInt(m[1], 10)) message_latency.update(+new Date() - parseInt(m[1], 10))
update_active_status: -> 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) -> send_stream_message: (stream, subject, content) ->
@post '/json/messages', { @post '/json/messages', {

View File

@ -55,7 +55,7 @@ def asynchronous(method):
def update_user_activity(request, user_profile): def update_user_activity(request, user_profile):
# update_active_status also pushes to rabbitmq, and it seems # update_active_status also pushes to rabbitmq, and it seems
# redundant to log that here as well. # 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 return
if hasattr(request, '_query'): if hasattr(request, '_query'):

View File

@ -1141,7 +1141,7 @@ class UserPresenceTests(AuthedTestCase):
self.assertEqual(list(json['presences'].keys()), ['hamlet@zulip.com']) self.assertEqual(list(json['presences'].keys()), ['hamlet@zulip.com'])
return json['presences'][email][client]['timestamp'] 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) test_result(result)
result = self.client.post("/json/get_active_statuses", {}) result = self.client.post("/json/get_active_statuses", {})
@ -1149,7 +1149,7 @@ class UserPresenceTests(AuthedTestCase):
email = "othello@zulip.com" email = "othello@zulip.com"
self.login(email) 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", {}) result = self.client.post("/json/get_active_statuses", {})
self.assert_json_success(result) self.assert_json_success(result)
json = ujson.loads(result.content) json = ujson.loads(result.content)
@ -1163,7 +1163,7 @@ class UserPresenceTests(AuthedTestCase):
self.login("hamlet@zulip.com") self.login("hamlet@zulip.com")
client = 'website' 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", {}) result = self.client.post("/json/get_active_statuses", {})
self.assert_json_success(result) self.assert_json_success(result)
@ -1172,14 +1172,14 @@ class UserPresenceTests(AuthedTestCase):
email = "othello@zulip.com" email = "othello@zulip.com"
self.login("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", {}) result = self.client.post("/json/get_active_statuses", {})
self.assert_json_success(result) self.assert_json_success(result)
json = ujson.loads(result.content) json = ujson.loads(result.content)
self.assertEqual(json['presences'][email][client]['status'], 'idle') self.assertEqual(json['presences'][email][client]['status'], 'idle')
self.assertEqual(json['presences']['hamlet@zulip.com'][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", {}) result = self.client.post("/json/get_active_statuses", {})
self.assert_json_success(result) self.assert_json_success(result)
json = ujson.loads(result.content) json = ujson.loads(result.content)
@ -1189,19 +1189,19 @@ class UserPresenceTests(AuthedTestCase):
def test_no_mit(self): def test_no_mit(self):
# MIT never gets a list of users # MIT never gets a list of users
self.login("espuser@mit.edu") 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) self.assert_json_success(result)
json = ujson.loads(result.content) json = ujson.loads(result.content)
self.assertEqual(json['presences'], {}) self.assertEqual(json['presences'], {})
def test_same_realm(self): def test_same_realm(self):
self.login("espuser@mit.edu") 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/") result = self.client.post("/accounts/logout/")
# Ensure we don't see hamlet@zulip.com information leakage # Ensure we don't see hamlet@zulip.com information leakage
self.login("hamlet@zulip.com") 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) self.assert_json_success(result)
json = ujson.loads(result.content) json = ujson.loads(result.content)
self.assertEqual(json['presences']["hamlet@zulip.com"]["website"]['status'], 'idle') self.assertEqual(json['presences']["hamlet@zulip.com"]["website"]['status'], 'idle')