Skip to content
Snippets Groups Projects
Commit 956b374c authored by Gospodin Bodurov's avatar Gospodin Bodurov
Browse files

Merge branch '401-display-registered-and-not-registered-in-email' into 'master'

[Email Thread] Display registered and not registered receivers

See merge request !26
parents 82515813 ef6422a9
No related branches found
Tags 0.9-rc1
1 merge request!26[Email Thread] Display registered and not registered receivers
......@@ -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) {
......@@ -198,7 +190,7 @@ function getBody(mime, part) {
}
export function decodeMimeBody(descriptor, mimeString) {
let mimeBody = mimeString.slice(
const mimeBody = mimeString.slice(
descriptor.indices.headersEnd,
descriptor.indices.to
);
......@@ -308,7 +300,9 @@ export function getPlain(mime, parts) {
break;
}
}
if (!plainPart) {
return "";
}
plain = decodeMimeBody(plainPart, mime);
return plain;
}
......
import dataUriToBlob from "data-uri-to-blob";
import libmime from 'libmime';
import union from 'lodash/union';
import {
fixNewLines,
......@@ -15,6 +16,15 @@ import { getCertificateChain } from "./signingUtilities";
const SIGNATURE_CONTENT_TYPE = "application/pkcs7-signature";
export const DEFAULT_ATTACHMENT_NAME = 'attachment';
const splitParticipants = participantsList => {
if (!participantsList) {
return [];
}
const participants = participantsList.map(participants => participants.split(",").map(p => p.trim()));
return union.apply(null, participants);
};
export const parseSMIME = smimeString => {
return new Promise(resolve => {
setTimeout(async () => {
......@@ -48,10 +58,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 +115,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.
Finish editing this message first!
Please register or to comment