diff --git a/bananas_server/application/bananas_server.py b/bananas_server/application/bananas_server.py index 5e12881..0946801 100644 --- a/bananas_server/application/bananas_server.py +++ b/bananas_server/application/bananas_server.py @@ -48,6 +48,7 @@ async def _send_content_entry(self, source, content_entry): md5sum=content_entry.md5sum, dependencies=content_entry.dependencies, tags=content_entry.tags, + upload_date=content_entry.upload_date, ) def get_by_content_id(self, content_id): diff --git a/bananas_server/index/local.py b/bananas_server/index/local.py index 4135882..3e8fc95 100644 --- a/bananas_server/index/local.py +++ b/bananas_server/index/local.py @@ -95,6 +95,8 @@ def _read_content_entry_version(self, content_type, unique_id, data, md5sum_mapp md5sum_partial = bytes.fromhex(data["md5sum-partial"]) md5sum = md5sum_mapping[content_type][unique_id][md5sum_partial] + upload_date = int(data["upload-date"].timestamp()) + dependencies = [] for dependency in data.get("dependencies", []): dep_content_type = get_content_type_from_name(dependency["content-type"]) @@ -130,6 +132,7 @@ def _read_content_entry_version(self, content_type, unique_id, data, md5sum_mapp "url": data.get("url", ""), "description": data.get("description", ""), "unique-id": unique_id, + "upload-date": upload_date, "md5sum": md5sum, "min-version": min_version, "max-version": max_version, @@ -151,6 +154,7 @@ def _read_content_entry_version(self, content_type, unique_id, data, md5sum_mapp size += 1 for tag in data.get("tags", []): size += len(tag) + 2 + size += 4 # upload_date if size > 1400: raise Exception("Entry would exceed OpenTTD packet size.") diff --git a/bananas_server/index/schema.py b/bananas_server/index/schema.py index cd09fc0..5bdb4ed 100644 --- a/bananas_server/index/schema.py +++ b/bananas_server/index/schema.py @@ -23,6 +23,7 @@ class Meta: description = fields.String(validate=validate.Length(max=511)) tags = fields.List(fields.String(validate=validate.Length(max=31))) md5sum = fields.Raw(validate=validate.Length(min=16, max=16)) + upload_date = fields.Integer(data_key="upload-date") min_version = fields.List(fields.Integer(), data_key="min-version", missing=None) max_version = fields.List(fields.Integer(), data_key="max-version", missing=None) raw_dependencies = fields.List( diff --git a/bananas_server/openttd/send.py b/bananas_server/openttd/send.py index 0ac20cf..1bf9267 100644 --- a/bananas_server/openttd/send.py +++ b/bananas_server/openttd/send.py @@ -16,7 +16,19 @@ class OpenTTDProtocolSend: async def send_PACKET_CONTENT_SERVER_INFO( - self, content_type, content_id, filesize, name, version, url, description, unique_id, md5sum, dependencies, tags + self, + content_type, + content_id, + filesize, + name, + version, + url, + description, + unique_id, + md5sum, + dependencies, + tags, + upload_date, ): data = write_init(PacketTCPContentType.PACKET_CONTENT_SERVER_INFO) @@ -53,6 +65,8 @@ async def send_PACKET_CONTENT_SERVER_INFO( for tag in tags: data = write_string(data, tag) + data = write_uint32(data, int(upload_date.timestamp())) + data = write_presend(data) await self.send_packet(data)