mirror of https://github.com/zulip/zulip.git
users: Remove short_name and client_id from get_profile_backend.
This commit removes short_name and client_id fields from the user objects returned by get_profile_backend because neither of them had a purpose. * short_name hasn't been present anywhere else in the Zulip API for several years, and isn't set through any coherent algorithm. * client_id was a forgotten 2013-era predecessor to the queue_id field returned by the register_event_queue process. The combination of these changes gets us close to having `get_profile` have the exact same format as other endpoints fetching a user object.
This commit is contained in:
parent
1f5778bad7
commit
7de23b8b5c
|
@ -14,6 +14,9 @@ below features are supported.
|
|||
|
||||
* [`GET users/me`](/api/get-profile): Added `avatar_version`, `is_guest`,
|
||||
`is_active`, `timezone`, and `date_joined` fields to the User objects.
|
||||
* [`GET users/me`](/api/get-profile): Removed `client_id` and `short_name`
|
||||
from the reponse to this endpoint. These fields had no purpose and
|
||||
were inconsistent with other API responses describing users.
|
||||
|
||||
**Feature level 9**
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ DESKTOP_WARNING_VERSION = "5.2.0"
|
|||
#
|
||||
# Changes should be accompanied by documentation explaining what the
|
||||
# new level means in templates/zerver/api/changelog.md.
|
||||
API_FEATURE_LEVEL = 9
|
||||
API_FEATURE_LEVEL = 10
|
||||
|
||||
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
||||
# only when going from an old version of the code to a newer version. Bump
|
||||
|
|
|
@ -1846,11 +1846,6 @@ paths:
|
|||
**Changes**: New in Zulip 2.2 (feature level 10). Previous
|
||||
versions do not return this field.
|
||||
example: 1
|
||||
client_id:
|
||||
type: string
|
||||
description: |
|
||||
NA
|
||||
example: "74c768b081076fdb3c4326256c17467e"
|
||||
email:
|
||||
type: string
|
||||
description: |
|
||||
|
@ -1926,11 +1921,6 @@ paths:
|
|||
|
||||
**Deprecated**. We plan to remove the `pointer` as a concept in Zulip.
|
||||
example: -1
|
||||
short_name:
|
||||
type: string
|
||||
description: |
|
||||
Short name of the requesting user.
|
||||
example: "iago"
|
||||
user_id:
|
||||
type: integer
|
||||
description: |
|
||||
|
@ -1942,7 +1932,6 @@ paths:
|
|||
{
|
||||
"avatar_url": "https://secure.gravatar.com/avatar/af4f06322c177ef4e1e9b2c424986b54?d=identicon&version=1",
|
||||
"avatar_version": 1,
|
||||
"client_id": "74c768b081076fdb3c4326256c17467e",
|
||||
"email": "iago@zulip.com",
|
||||
"full_name": "Iago",
|
||||
"is_admin": true,
|
||||
|
@ -1956,7 +1945,6 @@ paths:
|
|||
"msg": "",
|
||||
"pointer": -1,
|
||||
"result": "success",
|
||||
"short_name": "iago",
|
||||
"user_id": 5,
|
||||
"profile_data": {
|
||||
"5": {
|
||||
|
|
|
@ -696,10 +696,10 @@ class ListCustomProfileFieldTest(CustomProfileFieldTestCase):
|
|||
def test_get_custom_profile_fields_from_api_for_single_user(self) -> None:
|
||||
self.login('iago')
|
||||
expected_keys = {
|
||||
"result", "msg", "pointer", "client_id", "max_message_id", "user_id",
|
||||
"avatar_url", "full_name", "email", "is_bot", "is_admin", "is_owner",
|
||||
"short_name", "profile_data", "avatar_version", "timezone", "delivery_email",
|
||||
"is_active", "is_guest", "date_joined"}
|
||||
"result", "msg", "pointer", "max_message_id", "user_id", "avatar_url",
|
||||
"full_name", "email", "is_bot", "is_admin", "is_owner", "profile_data",
|
||||
"avatar_version", "timezone", "delivery_email", "is_active", "is_guest",
|
||||
"date_joined"}
|
||||
|
||||
url = "/json/users/me"
|
||||
response = self.client_get(url)
|
||||
|
|
|
@ -1337,7 +1337,6 @@ class GetProfileTest(ZulipTestCase):
|
|||
self.assert_json_success(result)
|
||||
json = result.json()
|
||||
|
||||
self.assertIn("client_id", json)
|
||||
self.assertIn("max_message_id", json)
|
||||
self.assertIn("pointer", json)
|
||||
|
||||
|
@ -1372,7 +1371,6 @@ class GetProfileTest(ZulipTestCase):
|
|||
|
||||
self.login('hamlet')
|
||||
result = ujson.loads(self.client_get('/json/users/me').content)
|
||||
self.assertEqual(result['short_name'], 'hamlet')
|
||||
self.assertEqual(result['email'], hamlet.email)
|
||||
self.assertEqual(result['full_name'], 'King Hamlet')
|
||||
self.assertIn("user_id", result)
|
||||
|
@ -1383,7 +1381,6 @@ class GetProfileTest(ZulipTestCase):
|
|||
self.assertFalse('delivery_email' in result)
|
||||
self.login('iago')
|
||||
result = ujson.loads(self.client_get('/json/users/me').content)
|
||||
self.assertEqual(result['short_name'], 'iago')
|
||||
self.assertEqual(result['email'], iago.email)
|
||||
self.assertEqual(result['full_name'], 'Iago')
|
||||
self.assertFalse(result['is_bot'])
|
||||
|
@ -1392,7 +1389,6 @@ class GetProfileTest(ZulipTestCase):
|
|||
self.assertFalse(result['is_guest'])
|
||||
self.login('desdemona')
|
||||
result = ujson.loads(self.client_get('/json/users/me').content)
|
||||
self.assertEqual(result['short_name'], 'desdemona')
|
||||
self.assertEqual(result['email'], desdemona.email)
|
||||
self.assertFalse(result['is_bot'])
|
||||
self.assertTrue(result['is_admin'])
|
||||
|
|
|
@ -31,7 +31,7 @@ from zerver.lib.users import check_valid_bot_type, check_bot_creation_policy, \
|
|||
check_full_name, check_short_name, check_valid_interface_type, check_valid_bot_config, \
|
||||
access_bot_by_id, add_service, access_user_by_id, check_bot_name_available, \
|
||||
validate_user_custom_profile_data, get_raw_user_data, get_api_key
|
||||
from zerver.lib.utils import generate_api_key, generate_random_token
|
||||
from zerver.lib.utils import generate_api_key
|
||||
from zerver.models import UserProfile, Stream, Message, \
|
||||
get_user_by_delivery_email, Service, get_user_including_cross_realm, \
|
||||
DomainNotAllowedForRealmError, DisposableEmailError, get_user_profile_by_id_in_realm, \
|
||||
|
@ -454,16 +454,11 @@ def create_user_backend(request: HttpRequest, user_profile: UserProfile,
|
|||
do_create_user(email, password, realm, full_name, short_name)
|
||||
return json_success()
|
||||
|
||||
def generate_client_id() -> str:
|
||||
return generate_random_token(32)
|
||||
|
||||
def get_profile_backend(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||
raw_user_data = get_raw_user_data(user_profile.realm, user_profile,
|
||||
client_gravatar=False, target_user=user_profile)
|
||||
result: Dict[str, Any] = raw_user_data[user_profile.id]
|
||||
|
||||
result['client_id'] = generate_client_id()
|
||||
result['short_name'] = user_profile.short_name
|
||||
result['max_message_id'] = -1
|
||||
result['pointer'] = user_profile.pointer
|
||||
|
||||
|
|
Loading…
Reference in New Issue