From c0bb39d4e30f41262e88c3498aca587106f49671 Mon Sep 17 00:00:00 2001 From: Ryan Miller Date: Thu, 2 May 2024 16:49:27 +1000 Subject: [PATCH] fix: add filesize constant --- ts/session/constants.ts | 9 +++++++++ ts/util/attachmentsUtil.ts | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ts/session/constants.ts b/ts/session/constants.ts index 806061e31..968f035f3 100644 --- a/ts/session/constants.ts +++ b/ts/session/constants.ts @@ -17,6 +17,15 @@ export const DURATION = { WEEKS: days * 7, }; +export const FILESIZE = { + /** 1KB */ + KB: 1024, + /** 1MB */ + MB: 1024 * 1024, + /** 1GB */ + GB: 1024 * 1024 * 1024, +}; + export const TTL_DEFAULT = { /** 20 seconds */ TYPING_MESSAGE: 20 * DURATION.SECONDS, diff --git a/ts/util/attachmentsUtil.ts b/ts/util/attachmentsUtil.ts index 3e5703848..7856ae076 100644 --- a/ts/util/attachmentsUtil.ts +++ b/ts/util/attachmentsUtil.ts @@ -13,7 +13,7 @@ import { IMAGE_GIF, IMAGE_JPEG, IMAGE_PNG, IMAGE_TIFF, IMAGE_UNKNOWN } from '../ import { getAbsoluteAttachmentPath, processNewAttachment } from '../types/MessageAttachment'; import { THUMBNAIL_SIDE } from '../types/attachments/VisualAttachment'; -import { MAX_ATTACHMENT_FILESIZE_BYTES } from '../session/constants'; +import { FILESIZE, MAX_ATTACHMENT_FILESIZE_BYTES } from '../session/constants'; import { perfEnd, perfStart } from '../session/utils/Performance'; /** @@ -54,7 +54,7 @@ export async function autoScaleForAvatar