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
No related tags found
1 merge request!26[Email Thread] Display registered and not registered receivers
...@@ -154,7 +154,7 @@ export function parseMIME(mime) { ...@@ -154,7 +154,7 @@ export function parseMIME(mime) {
parts.push({ parts.push({
indices: { from: 0, to: mime.length, headersEnd: headersEnd }, indices: { from: 0, to: mime.length, headersEnd: headersEnd },
headers: headers, headers,
boundary: "mimemessage" boundary: "mimemessage"
}); });
...@@ -162,19 +162,11 @@ export function parseMIME(mime) { ...@@ -162,19 +162,11 @@ export function parseMIME(mime) {
} }
function getHeaderValue(header, part) { function getHeaderValue(header, part) {
if (part.headers !== null && part.headers !== undefined) { if (part.headers && part.headers[header] && part.headers[header].length) {
if (part.headers[header] !== null && part.headers[header] !== undefined) { return part.headers[header];
if (part.headers[header].length > 0) {
return part.headers[header];
} else {
return null;
}
} else {
return null;
}
} else {
return null;
} }
return null;
} }
export function getGlobalHeaderValue(header, parts) { export function getGlobalHeaderValue(header, parts) {
...@@ -198,7 +190,7 @@ function getBody(mime, part) { ...@@ -198,7 +190,7 @@ function getBody(mime, part) {
} }
export function decodeMimeBody(descriptor, mimeString) { export function decodeMimeBody(descriptor, mimeString) {
let mimeBody = mimeString.slice( const mimeBody = mimeString.slice(
descriptor.indices.headersEnd, descriptor.indices.headersEnd,
descriptor.indices.to descriptor.indices.to
); );
...@@ -308,7 +300,9 @@ export function getPlain(mime, parts) { ...@@ -308,7 +300,9 @@ export function getPlain(mime, parts) {
break; break;
} }
} }
if (!plainPart) {
return "";
}
plain = decodeMimeBody(plainPart, mime); plain = decodeMimeBody(plainPart, mime);
return plain; return plain;
} }
......
import dataUriToBlob from "data-uri-to-blob"; import dataUriToBlob from "data-uri-to-blob";
import libmime from 'libmime'; import libmime from 'libmime';
import union from 'lodash/union';
import { import {
fixNewLines, fixNewLines,
...@@ -15,6 +16,15 @@ import { getCertificateChain } from "./signingUtilities"; ...@@ -15,6 +16,15 @@ import { getCertificateChain } from "./signingUtilities";
const SIGNATURE_CONTENT_TYPE = "application/pkcs7-signature"; const SIGNATURE_CONTENT_TYPE = "application/pkcs7-signature";
export const DEFAULT_ATTACHMENT_NAME = 'attachment'; 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 => { export const parseSMIME = smimeString => {
return new Promise(resolve => { return new Promise(resolve => {
setTimeout(async () => { setTimeout(async () => {
...@@ -48,10 +58,14 @@ export const parseSMIME = smimeString => { ...@@ -48,10 +58,14 @@ export const parseSMIME = smimeString => {
const certificateChain = getCertificateChain(signatureBase64); const certificateChain = getCertificateChain(signatureBase64);
const from = splitParticipants(getGlobalHeaderValue("from", parts));
const to = splitParticipants(getGlobalHeaderValue("to", parts));
const cc = splitParticipants(getGlobalHeaderValue("cc", parts));
const message = { const message = {
from: getGlobalHeaderValue("from", parts), from,
to: getGlobalHeaderValue("to", parts), to,
cc: getGlobalHeaderValue("cc", parts), cc,
subject: getGlobalHeaderValue("subject", parts).join(" "), subject: getGlobalHeaderValue("subject", parts).join(" "),
html: extractHtmlBodyFromString(html), html: extractHtmlBodyFromString(html),
plain, plain,
...@@ -101,4 +115,4 @@ export const extractHtmlBodyFromString = string => { ...@@ -101,4 +115,4 @@ export const extractHtmlBodyFromString = string => {
} }
return body; 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