From c1a2084d7c942089726e1a78ac206d040a6c066a Mon Sep 17 00:00:00 2001 From: Cyberes Date: Wed, 3 Apr 2024 23:25:30 -0600 Subject: [PATCH] fix max length, adjust strings --- exporter/callbacks.py | 4 ++-- exporter/config.py | 1 + exporter/export.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/exporter/callbacks.py b/exporter/callbacks.py index 2996ef3..dd43c03 100644 --- a/exporter/callbacks.py +++ b/exporter/callbacks.py @@ -162,13 +162,13 @@ class MatrixBotCallbacks: ) await aos.remove(zipfile_path) - self.logger.info(f'Export for {room.room_id} completed.') + self.logger.info(f'Export for {room.room_id} completed') self.exports.add_export(room.room_id, self.config['export_interval']) pub_url = f'{self.config["r2"]["pub_url"]}/{zipfile_name}' formatted_body = f'Export complete!
{pub_url}
This file will be deleted after 24 hours.' content = { - "body": f'Export complete!\n{pub_url}\nThis file will be deleted after 24 hours.', + "body": f'Export complete!\n{pub_url}\nThis file will be deleted after {self.config["r2"]["retention_hrs"]} hours.', "formatted_body": formatted_body, "format": "org.matrix.custom.html", "m.relates_to": { diff --git a/exporter/config.py b/exporter/config.py index 826cdfe..cca9e00 100644 --- a/exporter/config.py +++ b/exporter/config.py @@ -12,5 +12,6 @@ DEFAULT_CONFIG = { 'access_key_id': None, 'access_key_secret': None, 'pub_url': None, + 'retention_hrs': 24, } } diff --git a/exporter/export.py b/exporter/export.py index 72435b1..6f4f508 100644 --- a/exporter/export.py +++ b/exporter/export.py @@ -79,7 +79,7 @@ async def upload_to_r2(source_file: Union[str, Path], destination_file: str, buc return await bucket.upload_fileobj(f, destination_file) -def trim_filename(filename, max_length=255): +def trim_filename(filename, max_length=200): extension = os.path.splitext(filename)[1] max_length -= len(extension) if len(filename) > max_length: