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> </translation>
</translations> </translations>
</concept_node> </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> </children>
</folder_node> </folder_node>
<folder_node> <folder_node>

View File

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

View File

@@ -180,6 +180,23 @@ export function EmailOverlayComponent({
} }
return e && e.fileList; 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 <Upload.Dragger
beforeUpload={Upload.LIST_IGNORE} beforeUpload={Upload.LIST_IGNORE}

View File

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

View File

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

View File

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

View File

@@ -961,7 +961,8 @@
}, },
"errors": { "errors": {
"fcm": "You must allow notification permissions to have real time messaging. Click to try again.", "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": { "itemtypes": {
"contract": "CC Contract", "contract": "CC Contract",

View File

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

View File

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

View File

@@ -103,7 +103,7 @@ export default async function RenderTemplate(
}), }),
}, },
}; };
console.log("PDFREQ", pdfRequest);
const pdfRender = await jsreport.renderAsync(pdfRequest); const pdfRender = await jsreport.renderAsync(pdfRequest);
pdf = pdfRender.toDataURI(); 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"); let aws = require("aws-sdk");
const logger = require("../utils/logger"); const logger = require("../utils/logger");
const ses = new aws.SES({ const ses = new aws.SES({
apiVersion: "2010-12-01", apiVersion: "latest",
region: "ca-central-1", region: "ca-central-1",
}); });
@@ -43,6 +44,7 @@ exports.sendServerEmail = async function ({ subject, text }) {
} catch (error) { } catch (error) {
console.log(error); console.log(error);
logger.log("server-email-failure", "error", null, null, error); logger.log("server-email-failure", "error", null, null, error);
res.status(500).json(error);
} }
}; };
exports.sendTaskEmail = async function ({ to, subject, text, attachments }) { exports.sendTaskEmail = async function ({ to, subject, text, attachments }) {
@@ -153,7 +155,7 @@ exports.sendEmail = async (req, res) => {
error: err, 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