Skip to content
Snippets Groups Projects
Commit ebdc3358 authored by Alexey Lunin's avatar Alexey Lunin
Browse files

Split email participants by comma in to, from, cc fields

parent 6b1beabe
No related branches found
No related tags found
1 merge request!26[Email Thread] Display registered and not registered receivers
......@@ -28,6 +28,7 @@
"data-uri-to-blob": "^0.0.4",
"libmime": "^4.0.1",
"libqp": "^1.1.0",
"lodash": "^4.17.11",
"penpal": "^3.0.3",
"pkijs": "^2.1.69",
"pvutils": "^1.0.16",
......
......@@ -154,7 +154,7 @@ export function parseMIME(mime) {
parts.push({
indices: { from: 0, to: mime.length, headersEnd: headersEnd },
headers: headers,
headers,
boundary: "mimemessage"
});
......@@ -162,19 +162,11 @@ export function parseMIME(mime) {
}
function getHeaderValue(header, part) {
if (part.headers !== null && part.headers !== undefined) {
if (part.headers[header] !== null && part.headers[header] !== undefined) {
if (part.headers[header].length > 0) {
return part.headers[header];
} else {
return null;
}
} else {
return null;
}
} else {
return null;
if (part.headers && part.headers[header] && part.headers[header].length) {
return part.headers[header];
}
return null;
}
export function getGlobalHeaderValue(header, parts) {
......
import dataUriToBlob from "data-uri-to-blob";
import libmime from 'libmime';
import map from 'lodash/map';
import union from 'lodash/union';
import {
fixNewLines,
......@@ -15,6 +17,11 @@ import { getCertificateChain } from "./signingUtilities";
const SIGNATURE_CONTENT_TYPE = "application/pkcs7-signature";
export const DEFAULT_ATTACHMENT_NAME = 'attachment';
const splitParticipants = participantsList => {
const participants = map(participantsList, participants => participants.split(",").map(p => p.trim()));
return union.apply(null, participants);
};
export const parseSMIME = smimeString => {
return new Promise(resolve => {
setTimeout(async () => {
......@@ -48,10 +55,14 @@ export const parseSMIME = smimeString => {
const certificateChain = getCertificateChain(signatureBase64);
const from = splitParticipants(getGlobalHeaderValue("from", parts));
const to = splitParticipants(getGlobalHeaderValue("to", parts));
const cc = splitParticipants(getGlobalHeaderValue("cc", parts));
const message = {
from: getGlobalHeaderValue("from", parts),
to: getGlobalHeaderValue("to", parts),
cc: getGlobalHeaderValue("cc", parts),
from,
to,
cc,
subject: getGlobalHeaderValue("subject", parts).join(" "),
html: extractHtmlBodyFromString(html),
plain,
......@@ -101,4 +112,4 @@ export const extractHtmlBodyFromString = string => {
}
return body;
};
\ No newline at end of file
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment