candymail
Version:
Email Automation Library for Node.js
71 lines (70 loc) • 2.42 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.clearAllRows = exports.getEmailRowsToBeSent = exports.addEmailRow = exports.setEmailSent = exports.getAllEmailRows = void 0;
let emailsdb = [
{
body: 'asd',
sendTo: 'd',
sendFrom: 'd',
id: 1,
template: 'd',
sent: 0,
subject: 'sda',
time: '2020-08-20 02:20:30',
},
{
body: 'asd',
sendTo: 'd',
sendFrom: 'd',
id: 2,
template: 'd',
sent: 0,
subject: 'sda',
time: '2020-08-20 06:20:30',
},
];
const addEmailRow = (time, messageOptions) => {
const email = {
body: 'asd',
sendTo: messageOptions.sendTo,
sendFrom: messageOptions.sendFrom,
id: 1,
template: messageOptions.template,
sent: 0,
subject: 'sda',
time,
};
emailsdb.push(email);
};
exports.addEmailRow = addEmailRow;
const getEmailRowsToBeSent = () => __awaiter(void 0, void 0, void 0, function* () {
return Promise.resolve([emailsdb[0]]);
});
exports.getEmailRowsToBeSent = getEmailRowsToBeSent;
const getAllEmailRows = () => __awaiter(void 0, void 0, void 0, function* () {
return emailsdb;
});
exports.getAllEmailRows = getAllEmailRows;
const setEmailSent = (id) => __awaiter(void 0, void 0, void 0, function* () {
emailsdb.forEach((email, index, theArray) => {
if (email.id === id) {
email.sent = 1;
theArray[index] = email;
return;
}
});
});
exports.setEmailSent = setEmailSent;
const clearAllRows = () => __awaiter(void 0, void 0, void 0, function* () {
emailsdb = [];
});
exports.clearAllRows = clearAllRows;