Expose a users/me/presence API endpoint

(imported from commit 770310284e91ae20d766cd9a52dd1005b5e47e6b)
This commit is contained in:
Leo Franchi
2014-01-01 17:02:01 -06:00
parent 30367d0c0f
commit 72bfc12f18
2 changed files with 8 additions and 3 deletions

View File

@@ -2018,10 +2018,9 @@ def get_status_list(requesting_user_profile):
return {'presences': get_status_dict(requesting_user_profile),
'server_timestamp': time.time()}
@authenticated_json_post_view
@has_request_variables
def json_update_active_status(request, user_profile, status=REQ,
new_user_input=REQ(converter=json_to_bool, default=False)):
def update_active_status_backend(request, user_profile, status=REQ,
new_user_input=REQ(converter=json_to_bool, default=False)):
status_val = UserPresence.status_from_string(status)
if status_val is None:
raise JsonableError("Invalid presence status: %s" % (status,))
@@ -2044,6 +2043,10 @@ def json_update_active_status(request, user_profile, status=REQ,
return json_success(ret)
@authenticated_json_post_view
def json_update_active_status(request, user_profile):
return update_active_status_backend(request, user_profile)
@authenticated_json_post_view
def json_get_active_statuses(request, user_profile):
return json_success(get_status_list(user_profile))

View File

@@ -205,6 +205,8 @@ v1_api_and_json_patterns = patterns('zerver.views',
'DELETE': 'remove_alert_words'}),
url(r'^users/me/api_key/regenerate$', 'rest_dispatch',
{'POST': 'regenerate_api_key'}),
url(r'^users/me/presence$', 'rest_dispatch',
{'POST': 'update_active_status_backend'}),
# Endpoint used by iOS devices to register their
# unique APNS device token
url(r'^users/me/apns_device_token$', 'rest_dispatch',