sendemail function for gov notify
This commit is contained in:
@@ -328,6 +328,10 @@ export const uploadFile = async (formContent, containerName, foldername) => {
|
|||||||
const tags = {
|
const tags = {
|
||||||
containerid: containerName,
|
containerid: containerName,
|
||||||
caseID: foldername,
|
caseID: foldername,
|
||||||
|
documentType: files[prop][0].fieldName.slice(
|
||||||
|
0,
|
||||||
|
files[prop][0].fieldName.indexOf("_")
|
||||||
|
),
|
||||||
};
|
};
|
||||||
const withTags = await blockBlobClient.setTags(tags);
|
const withTags = await blockBlobClient.setTags(tags);
|
||||||
const withMeta = await blockBlobClient.setMetadata(tags);
|
const withMeta = await blockBlobClient.setMetadata(tags);
|
||||||
@@ -362,10 +366,13 @@ export const downloadProgressFile = async (
|
|||||||
const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
|
const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
|
||||||
const containerClient = new ContainerClient(sasUrl);
|
const containerClient = new ContainerClient(sasUrl);
|
||||||
const blobClient = containerClient.getBlobClient(blobName);
|
const blobClient = containerClient.getBlobClient(blobName);
|
||||||
const downloadedBlob = await blobClient.download(0);
|
const downloadedBlob = await blobClient.download();
|
||||||
|
|
||||||
const downloaded = await streamToBuffer(downloadedBlob.readableStreamBody);
|
const downloaded = await streamToBuffer(downloadedBlob.readableStreamBody);
|
||||||
return downloaded;
|
|
||||||
|
console.log("Downloaded blob content:", downloaded.toString());
|
||||||
|
|
||||||
|
return JSON.parse(downloaded.toString());
|
||||||
};
|
};
|
||||||
|
|
||||||
export const downloadAllProgressFiles = async (
|
export const downloadAllProgressFiles = async (
|
||||||
|
|||||||
+9
-9
@@ -1371,19 +1371,19 @@ export const getProgressFromBlob = async (containerName, casereference) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const sendEmail = async (
|
export const sendEmail = async (
|
||||||
emailToAddress,
|
templateId,
|
||||||
emailSubject,
|
emailAddress,
|
||||||
emailContentTitle,
|
personalisation,
|
||||||
emailContent
|
reference
|
||||||
) => {
|
) => {
|
||||||
var mailData = {
|
var mailData = {
|
||||||
"email": emailToAddress,
|
"templateId": templateId,
|
||||||
"subject": emailSubject,
|
"emailAddress": emailAddress,
|
||||||
"emailcontenttitle": emailContentTitle,
|
"reference": reference,
|
||||||
"emailcontent": emailContent,
|
"personalisation": personalisation,
|
||||||
};
|
};
|
||||||
|
|
||||||
var queryUrl = "/api/email";
|
var queryUrl = "/api/email/notify";
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
method: "post",
|
method: "post",
|
||||||
|
|||||||
@@ -1540,7 +1540,8 @@ const RenderFileUpload = (field) => {
|
|||||||
width="50"
|
width="50"
|
||||||
/>
|
/>
|
||||||
<span className="govuk-body govuk-!-font-size-14 govuk-!-padding-left-5">
|
<span className="govuk-body govuk-!-font-size-14 govuk-!-padding-left-5">
|
||||||
{file.name} ({bytesToSize(file.size)})
|
{file.name.slice(file.name.indexOf("_") + 1)} (
|
||||||
|
({bytesToSize(file.size)})
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -1588,7 +1589,8 @@ const RenderFileUpload = (field) => {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<a className="govuk-body govuk-!-font-size-14 govuk-!-padding-left-5 govuk-link">
|
<a className="govuk-body govuk-!-font-size-14 govuk-!-padding-left-5 govuk-link">
|
||||||
{blob.name} ({bytesToSize(blob.contentLength)})
|
{blob.name.slice(blob.name.indexOf("_") + 1)} (
|
||||||
|
{bytesToSize(blob.contentLength)})
|
||||||
</a>
|
</a>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -139,9 +139,9 @@ let BuildCheckSection = (props) => {
|
|||||||
</dl>
|
</dl>
|
||||||
<dl className="govuk-summary-list govuk-!-margin-bottom-9 at-summary-list">
|
<dl className="govuk-summary-list govuk-!-margin-bottom-9 at-summary-list">
|
||||||
<div className="govuk-summary-list__row" key={"9999"}>
|
<div className="govuk-summary-list__row" key={"9999"}>
|
||||||
<dt>
|
<dt className="govuk-summary-list__key">
|
||||||
{_.has(props.props.appealType.fileList.files) &&
|
{props.props.appealType.fileList.files.length >
|
||||||
props.props.appealType.fileList.files.length > 0
|
0
|
||||||
? props.props.appealType.fileList.files.map(
|
? props.props.appealType.fileList.files.map(
|
||||||
(blob, i) => (
|
(blob, i) => (
|
||||||
<div
|
<div
|
||||||
@@ -152,12 +152,21 @@ let BuildCheckSection = (props) => {
|
|||||||
src={getThumbnailIconByExtension(
|
src={getThumbnailIconByExtension(
|
||||||
blob.name
|
blob.name
|
||||||
)}
|
)}
|
||||||
alt={blob.name}
|
alt={blob.name.slice(
|
||||||
|
blob.name.indexOf(
|
||||||
|
"_"
|
||||||
|
) + 1
|
||||||
|
)}
|
||||||
width="50"
|
width="50"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<span className="govuk-body govuk-!-font-size-14 govuk-!-padding-left-5">
|
<span className="govuk-body govuk-!-font-size-14 govuk-!-padding-left-5">
|
||||||
{blob.name} (
|
{blob.name.slice(
|
||||||
|
blob.name.indexOf(
|
||||||
|
"_"
|
||||||
|
) + 1
|
||||||
|
)}
|
||||||
|
(
|
||||||
{bytesToSize(
|
{bytesToSize(
|
||||||
blob.contentLength
|
blob.contentLength
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -125,7 +125,11 @@ let BuildSection = (props) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateCaseProgress = (values, sendSavedEmail, useSaveStatus) => {
|
const updateCaseProgress = async (
|
||||||
|
values,
|
||||||
|
sendSavedEmail,
|
||||||
|
useSaveStatus
|
||||||
|
) => {
|
||||||
let incidentId = props.appealType.caseReference.incidentid;
|
let incidentId = props.appealType.caseReference.incidentid;
|
||||||
let updateBody = values || {};
|
let updateBody = values || {};
|
||||||
|
|
||||||
@@ -169,22 +173,13 @@ let BuildSection = (props) => {
|
|||||||
let updateFormCollection = appTypeCollection.LogicalCollectionName;
|
let updateFormCollection = appTypeCollection.LogicalCollectionName;
|
||||||
let primaryAttribute = appTypeCollection.PrimaryIdAttribute;
|
let primaryAttribute = appTypeCollection.PrimaryIdAttribute;
|
||||||
|
|
||||||
// updateCase(
|
const reference = "PEDW-PARTIAL";
|
||||||
// incidentId,
|
const templateId = "021b0a7b-df00-41f1-b94e-c269bee98c75";
|
||||||
// updateBody,
|
const emailAddress = props.props.accountDetails.loggedinUserEmail;
|
||||||
// updateFormCollection,
|
const personalisation = {
|
||||||
// primaryAttribute,
|
"caseReference": props.appealType.caseReference.ticketnumber,
|
||||||
// props.appealType.caseReference.ticketnumber
|
"emailAddress": props.props.accountDetails.loggedinUserEmail,
|
||||||
// );
|
"returnLink":
|
||||||
|
|
||||||
sendSavedEmail == true &&
|
|
||||||
sendEmail(
|
|
||||||
props.props.accountDetails.loggedinUserEmail,
|
|
||||||
"Saved progress for appeal " +
|
|
||||||
props.appealType.caseReference.ticketnumber,
|
|
||||||
"Your saved appeal " +
|
|
||||||
props.appealType.caseReference.ticketnumber,
|
|
||||||
"You can resume your application at a later date <a href='" +
|
|
||||||
props.props.url +
|
props.props.url +
|
||||||
"/myportal/" +
|
"/myportal/" +
|
||||||
appTypeCollection.UrlName +
|
appTypeCollection.UrlName +
|
||||||
@@ -195,9 +190,12 @@ let BuildSection = (props) => {
|
|||||||
"&casereference=" +
|
"&casereference=" +
|
||||||
props.appealType.caseReference.ticketnumber +
|
props.appealType.caseReference.ticketnumber +
|
||||||
"&inid=" +
|
"&inid=" +
|
||||||
props.appealType.caseReference.incidentid +
|
props.appealType.caseReference.incidentid,
|
||||||
"'> from here </a>"
|
"linkExpiry": 10 * 60,
|
||||||
);
|
};
|
||||||
|
|
||||||
|
sendSavedEmail == true &&
|
||||||
|
sendEmail(templateId, emailAddress, personalisation, reference);
|
||||||
|
|
||||||
useSaveStatus &&
|
useSaveStatus &&
|
||||||
router.replace(
|
router.replace(
|
||||||
|
|||||||
@@ -50,13 +50,15 @@ let CompleteAppeal = (props) => {
|
|||||||
props.appealType.caseReference.ticketnumber
|
props.appealType.caseReference.ticketnumber
|
||||||
);
|
);
|
||||||
|
|
||||||
sendEmail(
|
const reference = "PEDW-COMPLETE";
|
||||||
props.props.accountDetails.loggedinUserEmail,
|
const templateId = "618e0463-b092-4733-a024-bf8a3bbde808";
|
||||||
"Saved progress for appeal " +
|
const emailAddress = props.props.accountDetails.loggedinUserEmail;
|
||||||
props.appealType.caseReference.ticketnumber,
|
const personalisation = {
|
||||||
"Your saved appeal " + props.appealType.caseReference.ticketnumber,
|
"caseReference": props.appealType.caseReference.ticketnumber,
|
||||||
"You have now completed your appeal."
|
"emailAddress": props.props.accountDetails.loggedinUserEmail,
|
||||||
);
|
"linkExpiry": 10 * 60,
|
||||||
|
};
|
||||||
|
sendEmail(templateId, emailAddress, personalisation, reference);
|
||||||
|
|
||||||
console.log("patching////////");
|
console.log("patching////////");
|
||||||
patchCase(incidentId);
|
patchCase(incidentId);
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { consoleLogger } from "../../../actions";
|
||||||
|
|
||||||
|
export default async function ApiProxy(req, res) {
|
||||||
|
var data = req.body;
|
||||||
|
|
||||||
|
var NotifyClient = require("notifications-node-client").NotifyClient;
|
||||||
|
|
||||||
|
const notifyClient = new NotifyClient(process.env.NOTIFY_API_KEY);
|
||||||
|
//const emailReplyToId = process.env.EMAIL_REPLY_TO_ID;
|
||||||
|
|
||||||
|
notifyClient
|
||||||
|
.sendEmail(data.templateId, data.emailAddress, {
|
||||||
|
personalisation: data.personalisation,
|
||||||
|
reference: data.reference,
|
||||||
|
// emailReplyToId: emailReplyToId,
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
//console.log("thisis the response", response);
|
||||||
|
return res.status(200).json(data);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
consoleLogger(err);
|
||||||
|
return res.status(400).json(err);
|
||||||
|
});
|
||||||
|
//return res.status(200).json(data);
|
||||||
|
}
|
||||||
@@ -32,7 +32,8 @@ ApiProxy.get(async (req, res) => {
|
|||||||
|
|
||||||
res.setHeader(
|
res.setHeader(
|
||||||
"content-disposition",
|
"content-disposition",
|
||||||
"attachment; filename=" + decodeURI(blobName)
|
"attachment; filename=" +
|
||||||
|
decodeURI(blobName.slice(blobName.indexOf("_") + 1))
|
||||||
);
|
);
|
||||||
return res.status(200).send(downloaded);
|
return res.status(200).send(downloaded);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ ApiProxy.get(async (req, res) => {
|
|||||||
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||||
const blobObj = await getProgressBlobs(containerName, casefolderID)
|
const blobObj = await getProgressBlobs(containerName, casefolderID)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
console.log("ertyuikjhgfg", data.path);
|
||||||
return downloadProgressFile(containerName, data.path, casefolderID);
|
return downloadProgressFile(containerName, data.path, casefolderID);
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user