IO-1937 Add 10mb limit for emails.

This commit is contained in:
Patrick Fic
2022-06-17 15:22:29 -07:00
parent 7ba3cc5ffa
commit 1e88d5ae1b
13 changed files with 15461 additions and 3334 deletions

View File

@@ -15374,6 +15374,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>sizelimit</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
</children>
</folder_node>
<folder_node>

View File

@@ -38,6 +38,12 @@ export function EmailDocumentsComponent({
nextFetchPolicy: "network-only",
});
console.log(
selectedMedia &&
selectedMedia
.filter((s) => s.isSelected)
.reduce((acc, val) => (acc = acc + val.size), 0)
);
return (
<div>
{loading && <LoadingSpinner />}
@@ -45,6 +51,12 @@ export function EmailDocumentsComponent({
{selectedMedia.filter((s) => s.isSelected).length >= 10 ? (
<div style={{ color: "red" }}>{t("messaging.labels.maxtenimages")}</div>
) : null}
{selectedMedia &&
selectedMedia
.filter((s) => s.isSelected)
.reduce((acc, val) => (acc = acc + val.size), 0) >= 9961472 ? (
<div style={{ color: "red" }}>{t("general.errors.sizelimit")}</div>
) : null}
{data && (
<JobDocumentsGalleryExternal
data={data ? data.documents : []}

View File

@@ -180,6 +180,23 @@ export function EmailOverlayComponent({
}
return e && e.fileList;
}}
rules={[
({ getFieldValue }) => ({
validator(rule, value) {
const totalSize = value.reduce(
(acc, val) => (acc = acc + val.size),
0
);
const limit = 9961472;
if (totalSize > limit) {
return Promise.reject(t("general.errors.sizelimit"));
}
return Promise.resolve();
},
}),
]}
>
<Upload.Dragger
beforeUpload={Upload.LIST_IGNORE}

View File

@@ -30,6 +30,7 @@ class ErrorBoundary extends React.Component {
static getDerivedStateFromError(error) {
console.log("ErrorBoundary -> getDerivedStateFromError -> error", error);
return { hasErrored: true, error: error };
}

View File

@@ -25,6 +25,7 @@ function JobsDocumentGalleryExternal({
id: value.id,
type: value.type,
tags: [{ value: value.type, title: value.type }],
size: value.size,
});
}

View File

@@ -24,6 +24,8 @@ import {
selectBodyshop,
selectInstanceConflict,
} from "../../redux/user/user.selectors";
import * as Sentry from "@sentry/react";
import "./manage.page.styles.scss";
const ManageRootPage = lazy(() =>
@@ -407,7 +409,10 @@ export function Manage({ match, conflict, bodyshop }) {
<Content className="content-container">
<PartnerPingComponent />
<ErrorBoundary>{PageContent}</ErrorBoundary>
<Sentry.ErrorBoundary fallback={<ErrorBoundary />} showDialog>
{PageContent}
</Sentry.ErrorBoundary>
<BackTop />
<Footer>
<div

View File

@@ -961,7 +961,8 @@
},
"errors": {
"fcm": "You must allow notification permissions to have real time messaging. Click to try again.",
"notfound": "No record was found."
"notfound": "No record was found.",
"sizelimit": "The selected items exceed the size limit."
},
"itemtypes": {
"contract": "CC Contract",

View File

@@ -961,7 +961,8 @@
},
"errors": {
"fcm": "",
"notfound": ""
"notfound": "",
"sizelimit": ""
},
"itemtypes": {
"contract": "",

View File

@@ -961,7 +961,8 @@
},
"errors": {
"fcm": "",
"notfound": ""
"notfound": "",
"sizelimit": ""
},
"itemtypes": {
"contract": "",

View File

@@ -103,7 +103,7 @@ export default async function RenderTemplate(
}),
},
};
console.log("PDFREQ", pdfRequest);
const pdfRender = await jsreport.renderAsync(pdfRequest);
pdf = pdfRender.toDataURI();
}

12049
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,8 @@ let nodemailer = require("nodemailer");
let aws = require("aws-sdk");
const logger = require("../utils/logger");
const ses = new aws.SES({
apiVersion: "2010-12-01",
apiVersion: "latest",
region: "ca-central-1",
});
@@ -43,6 +44,7 @@ exports.sendServerEmail = async function ({ subject, text }) {
} catch (error) {
console.log(error);
logger.log("server-email-failure", "error", null, null, error);
res.status(500).json(error);
}
};
exports.sendTaskEmail = async function ({ to, subject, text, attachments }) {
@@ -153,7 +155,7 @@ exports.sendEmail = async (req, res) => {
error: err,
});
res.json({ success: false, error: err });
res.status(500).json({ success: false, error: err });
}
}
);

6670
yarn.lock

File diff suppressed because it is too large Load Diff