Added support for help text in custom fields.
Reimplemented the mechanism how campaign_messages are created.
This commit is contained in:
Tomas Bures 2019-07-22 23:54:24 +05:30
parent 025600e818
commit 4e4b77ca84
19 changed files with 223 additions and 200 deletions

View file

@ -1,10 +1,14 @@
'use strict';
const crypto = require('crypto');
module.exports = {
enforce,
cleanupFromPost,
filterObject,
castToInteger
castToInteger,
normalizeEmail,
hashEmail
};
function enforce(condition, message) {
@ -36,4 +40,22 @@ function castToInteger(id, msg) {
}
return val;
}
}
function normalizeEmail(email) {
const emailParts = email.split(/@/);
if (emailParts.length !== 2) {
return email;
}
const username = emailParts[0];
const domain = emailParts[1].toLowerCase();
return username + '@' + domain;
}
function hashEmail(email) {
return crypto.createHash('sha512').update(normalizeEmail(email)).digest("base64");
}