api: Remove (sender_)short_name from message APIs.

This commit is contained in:
Steve Howell 2020-07-16 12:29:18 +00:00 committed by Tim Abbott
parent e6974d3013
commit b375581f58
11 changed files with 13 additions and 40 deletions

View File

@ -8,6 +8,15 @@ server versions is to check the `zulip_feature_level` parameter in the
`/register` and `/server_settings` responses to determine which of the
below features are supported.
## Changes in Zulip 3.1
**Feature level 26**
* The `sender_short_name` field is no longer included in
`GET /messages`.
* The `short_name` field is removed from `display_recipients`
in `GET /messages`.
## Changes in Zulip 3.0
**Feature level 25**

View File

@ -76,7 +76,7 @@ for msg in result['messages']:
continue
# Remove extraneous metadata
for k in ['flags', 'edit_history', 'topic_links',
'avatar_url', 'recipient_id', 'sender_short_name',
'avatar_url', 'recipient_id',
'content_type', 'client', 'sender_realm_str', 'id', 'type']:
msg.pop(k, None)
messages.append(msg)

View File

@ -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 = 25
API_FEATURE_LEVEL = 26
# 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

View File

@ -16,7 +16,6 @@ display_recipient_fields = [
"id",
"email",
"full_name",
"short_name",
"is_mirror_dummy",
]

View File

@ -445,7 +445,6 @@ class MessageDict:
query = UserProfile.objects.values(
'id',
'full_name',
'short_name',
'delivery_email',
'email',
'realm__string_id',
@ -465,7 +464,6 @@ class MessageDict:
sender_id = obj['sender_id']
user_row = sender_dict[sender_id]
obj['sender_full_name'] = user_row['full_name']
obj['sender_short_name'] = user_row['short_name']
obj['sender_email'] = user_row['email']
obj['sender_delivery_email'] = user_row['delivery_email']
obj['sender_realm_str'] = user_row['realm__string_id']
@ -487,7 +485,6 @@ class MessageDict:
sender_is_mirror_dummy = obj['sender_is_mirror_dummy']
sender_email = obj['sender_email']
sender_full_name = obj['sender_full_name']
sender_short_name = obj['sender_short_name']
sender_id = obj['sender_id']
if recipient_type == Recipient.STREAM:
@ -501,7 +498,6 @@ class MessageDict:
recip: UserDisplayRecipient = {
'email': sender_email,
'full_name': sender_full_name,
'short_name': sender_short_name,
'id': sender_id,
'is_mirror_dummy': sender_is_mirror_dummy,
}

View File

@ -35,7 +35,6 @@ ProfileFieldData = Dict[str, Union[Dict[str, str], str]]
class UserDisplayRecipient(TypedDict):
email: str
full_name: str
short_name: str
id: int
is_mirror_dummy: bool
DisplayRecipientT = Union[str, List[UserDisplayRecipient]]

View File

@ -182,7 +182,6 @@ paths:
"sender_full_name": "Othello Bot",
"sender_id": 13215,
"sender_realm_str": "example",
"sender_short_name": "othello-bot",
"topic": "Castle",
"topic_links": [],
"timestamp": 1375978403,
@ -204,7 +203,6 @@ paths:
"email": "hamlet@example.com",
"full_name": "Hamlet of Denmark",
"id": 31572,
"short_name": "hamlet",
},
],
"id": 12345679,
@ -213,7 +211,6 @@ paths:
"sender_full_name": "Othello Bot",
"sender_id": 13215,
"sender_realm_str": "example",
"sender_short_name": "othello-bot",
"subject": "",
"topic_links": [],
"timestamp": 1375978404,
@ -636,21 +633,18 @@ paths:
"display_recipient":
[
{
"short_name": "hamlet",
"id": 4,
"is_mirror_dummy": false,
"email": "hamlet@zulip.com",
"full_name": "King Hamlet",
},
{
"short_name": "iago",
"id": 5,
"is_mirror_dummy": false,
"email": "iago@zulip.com",
"full_name": "Iago",
},
{
"short_name": "prospero",
"id": 8,
"is_mirror_dummy": false,
"email": "prospero@zulip.com",
@ -659,7 +653,6 @@ paths:
],
"content_type": "text/html",
"is_me_message": false,
"sender_short_name": "hamlet",
"timestamp": 1527921326,
"sender_id": 4,
"sender_full_name": "King Hamlet",
@ -682,7 +675,6 @@ paths:
"display_recipient": "Verona",
"content_type": "text/html",
"is_me_message": false,
"sender_short_name": "hamlet",
"timestamp": 1527939746,
"sender_id": 4,
"sender_full_name": "King Hamlet",
@ -4354,7 +4346,6 @@ paths:
"is_me_message": false,
"reactions": [],
"sender_realm_str": "zulip",
"sender_short_name": "iago",
},
"bot_email": "outgoing-bot@localhost",
}
@ -4452,10 +4443,6 @@ components:
type: string
description: |
Full name of the user.
short_name:
type: string
description: |
Short name of the user.
is_mirror_dummy:
type: boolean
description: |
@ -4542,10 +4529,6 @@ components:
type: string
description: |
Full name of the user.
short_name:
type: string
description: |
Short name of the user.
is_mirror_dummy:
type: boolean
description: |
@ -4575,10 +4558,6 @@ components:
the context of a given Zulip server.
E.g. on `example.zulip.com`, this will be `example`.
sender_short_name:
type: string
description: |
Reserved for future use.
stream_id:
type: integer
description: |

View File

@ -376,7 +376,6 @@ class NormalActionsTest(BaseAction):
('sender_email', check_string),
('sender_full_name', check_string),
('sender_id', check_int),
('sender_short_name', check_string),
('stream_id', check_int),
(TOPIC_NAME, check_string),
(TOPIC_LINKS, check_list(check_string)),
@ -2092,7 +2091,6 @@ class NormalActionsTest(BaseAction):
('content_type', equals('text/html')),
('sender_email', equals('notification-bot@zulip.com')),
('sender_id', check_int),
('sender_short_name', equals('notification-bot')),
('display_recipient', equals(new_name)),
('id', check_int),
('stream_id', check_int),

View File

@ -347,7 +347,6 @@ class MessageHydrationTest(ZulipTestCase):
sender_is_mirror_dummy=False,
sender_email=cordelia.email,
sender_full_name=cordelia.full_name,
sender_short_name=cordelia.short_name,
sender_id=cordelia.id,
)
@ -362,7 +361,6 @@ class MessageHydrationTest(ZulipTestCase):
dict(
email='aaron@example.com',
full_name='Aaron Smith',
short_name='Aaron',
id=999,
is_mirror_dummy=False,
),
@ -374,7 +372,6 @@ class MessageHydrationTest(ZulipTestCase):
sender_is_mirror_dummy=False,
sender_email=cordelia.email,
sender_full_name=cordelia.full_name,
sender_short_name=cordelia.short_name,
sender_id=cordelia.id,
)
@ -386,7 +383,6 @@ class MessageHydrationTest(ZulipTestCase):
dict(
email='aaron@example.com',
full_name='Aaron Smith',
short_name='Aaron',
id=999,
is_mirror_dummy=False,
),
@ -394,7 +390,6 @@ class MessageHydrationTest(ZulipTestCase):
email=cordelia.email,
full_name=cordelia.full_name,
id=cordelia.id,
short_name=cordelia.short_name,
is_mirror_dummy=False,
),
],
@ -482,7 +477,7 @@ class MessageHydrationTest(ZulipTestCase):
# Find which display_recipient in the list is cordelia:
for display_recipient in message['display_recipient']:
if display_recipient['short_name'] == 'cordelia':
if display_recipient['id'] == cordelia.id:
cordelia_display_recipient = display_recipient
# Make sure the email is up-to-date.
@ -499,7 +494,6 @@ class TestMessageForIdsDisplayRecipientFetching(ZulipTestCase):
recipient_dict: UserDisplayRecipient = {
'email': user_profile.email,
'full_name': user_profile.full_name,
'short_name': user_profile.short_name,
'id': user_profile.id,
'is_mirror_dummy': user_profile.is_mirror_dummy,
}

View File

@ -1066,7 +1066,7 @@ class GetOldMessagesTest(ZulipTestCase):
for message in result["messages"]:
for field in ("content", "content_type", "display_recipient",
"avatar_url", "recipient_id", "sender_full_name",
"sender_short_name", "timestamp", "reactions"):
"timestamp", "reactions"):
self.assertIn(field, message)
return result

View File

@ -89,7 +89,6 @@ class TestGenericOutgoingWebhookService(ZulipTestCase):
'sender_full_name': 'Othello, the Moor of Venice',
'sender_id': othello.id,
'sender_realm_str': 'zulip',
'sender_short_name': 'othello',
'stream_id': stream.id,
TOPIC_NAME: 'test',
'submessages': [],