Introduce smaller incoming size limit for text attachments
This commit is contained in:
parent
8c71ed2590
commit
5e733059b9
7 changed files with 85 additions and 31 deletions
|
@ -29,6 +29,7 @@ import * as log from '../logging/log';
|
|||
import {
|
||||
KIBIBYTE,
|
||||
getMaximumIncomingAttachmentSizeInKb,
|
||||
getMaximumIncomingTextAttachmentSizeInKb,
|
||||
} from '../types/AttachmentSize';
|
||||
|
||||
const {
|
||||
|
@ -281,14 +282,23 @@ async function _runJob(job?: AttachmentDownloadJobType): Promise<void> {
|
|||
let downloaded: AttachmentType | null = null;
|
||||
|
||||
try {
|
||||
const { size } = attachment;
|
||||
const maxInKib = getMaximumIncomingAttachmentSizeInKb(getValue);
|
||||
const maxTextAttachmentSizeInKib =
|
||||
getMaximumIncomingTextAttachmentSizeInKb(getValue);
|
||||
|
||||
const { size } = attachment;
|
||||
const sizeInKib = size / KIBIBYTE;
|
||||
|
||||
if (!size || sizeInKib > maxInKib) {
|
||||
throw new AttachmentSizeError(
|
||||
`Attachment Job ${id}: Attachment was ${sizeInKib}kib, max is ${maxInKib}kib`
|
||||
);
|
||||
}
|
||||
if (type === 'long-message' && sizeInKib > maxTextAttachmentSizeInKib) {
|
||||
throw new AttachmentSizeError(
|
||||
`Attachment Job ${id}: Text attachment was ${sizeInKib}kib, max is ${maxTextAttachmentSizeInKib}kib`
|
||||
);
|
||||
}
|
||||
|
||||
await _addAttachmentToMessage(
|
||||
message,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue