2022-10-20 23:39:33 -03:00
|
|
|
function match(message, headers) {
|
|
|
|
for (let header in headers) {
|
|
|
|
if (message.headers[header] !== headers[header]) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function body(message) {
|
2022-10-21 00:31:35 -03:00
|
|
|
if (message["body"] !== undefined) {
|
|
|
|
if (message["body"][0]["content-type"] === "text/plain") {
|
|
|
|
return message["body"][0]["content"];
|
|
|
|
}
|
|
|
|
/* istanbul ignore else */
|
|
|
|
if (message["body"][0]["content-type"] === "multipart/signed") {
|
|
|
|
return message["body"][0]["content"][0]["content"];
|
|
|
|
}
|
2022-10-20 23:39:33 -03:00
|
|
|
}
|
2022-10-21 00:31:35 -03:00
|
|
|
return undefined;
|
2022-10-20 23:39:33 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
function string(message) {
|
|
|
|
let string = "";
|
|
|
|
if (message["headers"]["From"] !== undefined) {
|
|
|
|
string += "From: " + message["headers"]["From"] + "\n";
|
|
|
|
}
|
|
|
|
/* istanbul ignore else */
|
|
|
|
if (message["headers"]["Date"] !== undefined) {
|
|
|
|
string += "Date: " + message["headers"]["Date"] + "\n";
|
|
|
|
}
|
|
|
|
/* istanbul ignore else */
|
|
|
|
if (message["headers"]["Subject"] !== undefined) {
|
|
|
|
string += "Subject: " + message["headers"]["Subject"] + "\n";
|
|
|
|
}
|
|
|
|
if (message["headers"]["To"] !== undefined) {
|
|
|
|
|
|
|
|
string += "To: " + message["headers"]["To"] + "\n";
|
|
|
|
}
|
|
|
|
if (message["body"] !== undefined) {
|
|
|
|
string += "\n";
|
|
|
|
string += body(message);
|
|
|
|
}
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.match = match;
|
|
|
|
exports.body = body;
|
|
|
|
exports.string = string;
|