mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
Expose a users/me/presence API endpoint
(imported from commit 770310284e91ae20d766cd9a52dd1005b5e47e6b)
This commit is contained in:
@@ -2018,10 +2018,9 @@ def get_status_list(requesting_user_profile):
|
|||||||
return {'presences': get_status_dict(requesting_user_profile),
|
return {'presences': get_status_dict(requesting_user_profile),
|
||||||
'server_timestamp': time.time()}
|
'server_timestamp': time.time()}
|
||||||
|
|
||||||
@authenticated_json_post_view
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
def json_update_active_status(request, user_profile, status=REQ,
|
def update_active_status_backend(request, user_profile, status=REQ,
|
||||||
new_user_input=REQ(converter=json_to_bool, default=False)):
|
new_user_input=REQ(converter=json_to_bool, default=False)):
|
||||||
status_val = UserPresence.status_from_string(status)
|
status_val = UserPresence.status_from_string(status)
|
||||||
if status_val is None:
|
if status_val is None:
|
||||||
raise JsonableError("Invalid presence status: %s" % (status,))
|
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)
|
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
|
@authenticated_json_post_view
|
||||||
def json_get_active_statuses(request, user_profile):
|
def json_get_active_statuses(request, user_profile):
|
||||||
return json_success(get_status_list(user_profile))
|
return json_success(get_status_list(user_profile))
|
||||||
|
|||||||
@@ -205,6 +205,8 @@ v1_api_and_json_patterns = patterns('zerver.views',
|
|||||||
'DELETE': 'remove_alert_words'}),
|
'DELETE': 'remove_alert_words'}),
|
||||||
url(r'^users/me/api_key/regenerate$', 'rest_dispatch',
|
url(r'^users/me/api_key/regenerate$', 'rest_dispatch',
|
||||||
{'POST': 'regenerate_api_key'}),
|
{'POST': 'regenerate_api_key'}),
|
||||||
|
url(r'^users/me/presence$', 'rest_dispatch',
|
||||||
|
{'POST': 'update_active_status_backend'}),
|
||||||
# Endpoint used by iOS devices to register their
|
# Endpoint used by iOS devices to register their
|
||||||
# unique APNS device token
|
# unique APNS device token
|
||||||
url(r'^users/me/apns_device_token$', 'rest_dispatch',
|
url(r'^users/me/apns_device_token$', 'rest_dispatch',
|
||||||
|
|||||||
Reference in New Issue
Block a user