Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

attachments: Change timestamp format to normal UNIX timestamp.

Vector7369f52b3b3c53
diff --git a/api_docs/changelog.md b/api_docs/changelog.md
index a1a00b42d85..c5242907962 100644
--- a/api_docs/changelog.md
+++ b/api_docs/changelog.md
@@ -20,6 +20,16 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 12.0
+**Feature level 443**
+
+* [`GET /attachments`](/api/get-attachments), [`GET /events`](/api/get-events):
+ The `create_time` and `date_sent` fields in `attachment` objects will now
+ return UNIX timestamps in seconds. Previously, these values were returned in
+ milliseconds.
+* [`PATCH /messages/{message_id}`](/api/update-message): The `create_time` and
+ `date_sent` fields in `detached_uploads` object will now return UNIX timestamps
+ in seconds. Previously, these values were returned in milliseconds.
+
**Feature level 442**
* [`GET /events`](/api/get-events): `giphy_rating` is now used to denote
diff --git a/version.py b/version.py
index a26ef80cb49..daabc640efe 100644
--- a/version.py
+++ b/version.py
@@ -35,7 +35,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"
# new level means in api_docs/changelog.md, as well as "**Changes**"
# entries in the endpoint's documentation in `zulip.yaml`.
-API_FEATURE_LEVEL = 442
+API_FEATURE_LEVEL = 443
# 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
diff --git a/web/src/attachments_ui.ts b/web/src/attachments_ui.ts
index 50b47726269..c2653758c61 100644
--- a/web/src/attachments_ui.ts
+++ b/web/src/attachments_ui.ts
@@ -190,7 +190,7 @@ function render_attachments_ui(): void {
function format_attachment_data(attachment: ServerAttachment): Attachment {
return {
...attachment,
- create_time_str: timerender.render_now(new Date(attachment.create_time)).time_str,
+ create_time_str: timerender.render_now(new Date(attachment.create_time * 1000)).time_str,
size_str: bytes_to_size(attachment.size),
};
}
diff --git a/zerver/models/messages.py b/zerver/models/messages.py
index 51e9c6215c0..f03e110ffcd 100644
--- a/zerver/models/messages.py
+++ b/zerver/models/messages.py
@@ -811,13 +811,11 @@ class Attachment(AbstractAttachment):
"name": self.file_name,
"path_id": self.path_id,
"size": self.size,
- # convert to JavaScript-style UNIX timestamp so we can take
- # advantage of client time zones.
- "create_time": int(time.mktime(self.create_time.timetuple()) * 1000),
+ "create_time": int(time.mktime(self.create_time.timetuple())),
"messages": [
{
"id": m.id,
- "date_sent": int(time.mktime(m.date_sent.timetuple()) * 1000),
+ "date_sent": int(time.mktime(m.date_sent.timetuple())),
}
for m in self.messages.all()
],
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 59b8ef906cb..83cd94484fd 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -1684,7 +1684,7 @@ paths:
"name": "zulip.txt",
"path_id": "2/ce/2Xpnnwgh8JWKxBXtTfD6BHKV/zulip.txt",
"size": 6,
- "create_time": 1594825414000,
+ "create_time": 1594825414,
"messages": [],
},
"upload_space_used": 6,
@@ -1725,7 +1725,7 @@ paths:
"name": "zulip.txt",
"path_id": "2/ce/2Xpnnwgh8JWKxBXtTfD6BHKV/zulip.txt",
"size": 6,
- "create_time": 1594825414000,
+ "create_time": 1594825414,
"messages": [],
},
"upload_space_used": 6,
@@ -6502,11 +6502,11 @@ paths:
"name": "166050.jpg",
"path_id": "2/ce/DfOkzwdg_IwlrN3myw3KGtiJ/166050.jpg",
"size": 571946,
- "create_time": 1588145417000,
+ "create_time": 1588145417,
"messages":
[
- {"id": 102, "date_sent": 1588145424000},
- {"id": 103, "date_sent": 1588145448000},
+ {"id": 102, "date_sent": 1588145424},
+ {"id": 103, "date_sent": 1588145448},
],
},
],
@@ -9888,7 +9888,7 @@ paths:
"name": "1253601-1.jpg",
"path_id": "2/5d/BD5NRptFxPDKY3RUKwhhup8r/1253601-1.jpg",
"size": 1339060,
- "create_time": 1687984706000,
+ "create_time": 1687984706,
"messages": [],
},
],
@@ -25144,10 +25144,12 @@ components:
create_time:
type: integer
description: |
- Time when the attachment was uploaded as a UNIX timestamp
- multiplied by 1000 (matching the format of getTime() in JavaScript).
+ Time when the attachment was uploaded as a UNIX timestamp.
- **Changes**: Changed in Zulip 3.0 (feature level 22). This field was
+ **Changes**: Before Zulip 12.0 (feature level 443), this value
+ was milliseconds since the epoch, not seconds.
+
+ Changed in Zulip 3.0 (feature level 22). This field was
previously a floating point number.
messages:
type: array
@@ -25164,10 +25166,12 @@ components:
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).
+ Time when the message was sent as a UNIX timestamp.
+
+ **Changes**: Before Zulip 12.0 (feature level 443), this value
+ was milliseconds since the epoch, not seconds.
- **Changes**: Changed in Zulip 3.0 (feature level 22). This
+ Changed in Zulip 3.0 (feature level 22). This
field was previously strangely called `name` and was a floating
point number.
id: