attachments: Change data type and make variable names more accurate.

Change variable `name` to `date_sent` as `name` actually stores
the date sent. Also change the data types of `name` and `create_time`
to integer. As they actually have empty decimal value.
This commit is contained in:
orientor 2020-06-24 13:58:00 +05:30 committed by Tim Abbott
parent 4a88e2a732
commit f188708b20
4 changed files with 24 additions and 14 deletions

View File

@ -10,6 +10,12 @@ below features are supported.
## Changes in Zulip 3.0
**Feature level 22**
* 'GET /attachments': Rename `name` to `date_sent` for clearer meaning
and change the data types of the new `date_sent` and `create_time`
to integer (previously the implementation could send floats).
**Feature level 21**
* `PATCH /settings/display`: Replaced the `night_mode` boolean with

View File

@ -2114,10 +2114,10 @@ class Attachment(AbstractAttachment):
'size': self.size,
# convert to JavaScript-style UNIX timestamp so we can take
# advantage of client timezones.
'create_time': time.mktime(self.create_time.timetuple()) * 1000,
'create_time': int(time.mktime(self.create_time.timetuple()) * 1000),
'messages': [{
'id': m.id,
'name': time.mktime(m.date_sent.timetuple()) * 1000,
'date_sent': int(time.mktime(m.date_sent.timetuple()) * 1000),
} for m in self.messages.all()],
}

View File

@ -386,11 +386,13 @@ paths:
description: |
Size of the file in bytes.
create_time:
# TODO: Make this value always return integers.
type: number
type: integer
description: |
Time when the attachment was uploaded as a UNIX timestamp
multiplied by 1000 (matching the format of getTime() in JavaScript).
**Changes**: Changed in Zulip 2.2 (feature level 22). This field was
previously a floating point number.
messages:
type: array
description: |
@ -402,13 +404,15 @@ paths:
items:
type: object
properties:
name:
type: number
date_sent:
type: integer
description: |
Time when the message was sent as a UNIX timestamp
multiplied by 1000 (matching the format of getTime() in JavaScript).
**Deprecated**: We plan to rename this field.
**Changes**: Changed in Zulip 2.2 (feature level 22). This
field was previously strangely called `name` and was a floating
point number.
id:
type: integer
description: |
@ -429,15 +433,15 @@ paths:
"name": "166050.jpg",
"path_id": "2/ce/DfOkzwdg_IwlrN3myw3KGtiJ/166050.jpg",
"size": 571946,
"create_time": 1588145417000.0,
"create_time": 1588145417000,
"messages": [
{
"id": 102,
"name": 1588145424000.0
"date_sent": 1588145424000
},
{
"id": 103,
"name": 1588145448000.0
"date_sent": 1588145448000
}
]
}

View File

@ -2737,10 +2737,10 @@ class EventsRegisterTest(ZulipTestCase):
('name', check_string),
('size', check_int),
('path_id', check_string),
('create_time', check_float),
('create_time', check_int),
('messages', check_list(check_dict_only([
('id', check_int),
('name', check_float),
('date_sent', check_int),
]))),
])),
('upload_space_used', equals(6)),
@ -2779,10 +2779,10 @@ class EventsRegisterTest(ZulipTestCase):
('name', check_string),
('size', check_int),
('path_id', check_string),
('create_time', check_float),
('create_time', check_int),
('messages', check_list(check_dict_only([
('id', check_int),
('name', check_float),
('date_sent', check_int),
]))),
])),
('upload_space_used', equals(6)),