fix max length, adjust strings
This commit is contained in:
parent
0bf5d92f1a
commit
c1a2084d7c
|
@ -162,13 +162,13 @@ class MatrixBotCallbacks:
|
||||||
)
|
)
|
||||||
await aos.remove(zipfile_path)
|
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'])
|
self.exports.add_export(room.room_id, self.config['export_interval'])
|
||||||
|
|
||||||
pub_url = f'{self.config["r2"]["pub_url"]}/{zipfile_name}'
|
pub_url = f'{self.config["r2"]["pub_url"]}/{zipfile_name}'
|
||||||
formatted_body = f'<strong>Export complete!</strong><br><a href="{pub_url}">{pub_url}</a><br>This file will be deleted after 24 hours.'
|
formatted_body = f'<strong>Export complete!</strong><br><a href="{pub_url}">{pub_url}</a><br>This file will be deleted after 24 hours.'
|
||||||
content = {
|
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,
|
"formatted_body": formatted_body,
|
||||||
"format": "org.matrix.custom.html",
|
"format": "org.matrix.custom.html",
|
||||||
"m.relates_to": {
|
"m.relates_to": {
|
||||||
|
|
|
@ -12,5 +12,6 @@ DEFAULT_CONFIG = {
|
||||||
'access_key_id': None,
|
'access_key_id': None,
|
||||||
'access_key_secret': None,
|
'access_key_secret': None,
|
||||||
'pub_url': None,
|
'pub_url': None,
|
||||||
|
'retention_hrs': 24,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
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]
|
extension = os.path.splitext(filename)[1]
|
||||||
max_length -= len(extension)
|
max_length -= len(extension)
|
||||||
if len(filename) > max_length:
|
if len(filename) > max_length:
|
||||||
|
|
Loading…
Reference in New Issue