mirror of https://github.com/zulip/zulip.git
presence.py: Enforce bots cannot use update_active_status_backend.
We need to keep the UserActivity table clean now that we're using it to compute 15day actives in analytics.
This commit is contained in:
parent
f62b8ea080
commit
bbddbdeb25
|
@ -264,6 +264,12 @@ class SingleUserPresenceTests(ZulipTestCase):
|
|||
result = self.client_post("/json/users/me/presence", req)
|
||||
self.assertEqual(result.json()['msg'], '')
|
||||
|
||||
def test_bot_post(self):
|
||||
# type: () -> None
|
||||
result = self.client_post("/api/v1/users/me/presence", {'status': 'active'},
|
||||
**self.api_auth('default-bot@zulip.com'))
|
||||
self.assert_json_error(result, "Presence is not supported for bot users.")
|
||||
|
||||
class UserPresenceAggregationTests(ZulipTestCase):
|
||||
def _send_presence_for_aggregated_tests(self, email, status, validate_time):
|
||||
# type: (str, str, datetime.datetime) -> Dict[str, Dict[str, Any]]
|
||||
|
|
|
@ -57,6 +57,9 @@ def update_active_status_backend(request, user_profile, status=REQ(),
|
|||
ping_only=REQ(validator=check_bool, default=False),
|
||||
new_user_input=REQ(validator=check_bool, default=False)):
|
||||
# type: (HttpRequest, UserProfile, str, bool, bool) -> HttpResponse
|
||||
if user_profile.is_bot:
|
||||
return json_error(_('Presence is not supported for bot users.'))
|
||||
|
||||
status_val = UserPresence.status_from_string(status)
|
||||
if status_val is None:
|
||||
raise JsonableError(_("Invalid status: %s") % (status,))
|
||||
|
|
Loading…
Reference in New Issue