Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let storiesOfMatch = storiesOf.exec(story)
let add = /(?:add\([\n\s]*)(?:')(.+)(?:',)/gim
let addMatch = add.exec(story)
while (addMatch !== null) {
data.storybookParams.push({
path: 'Storybook/' + addMatch[1].replace('\\', ''),
params: '?selectedKind=' + encodeURI(storiesOfMatch[1]) + '&selectedStory=' + encodeURI(addMatch[1])
})
addMatch = add.exec(story)
}
// Add check for no-ssr folder.
// Render template.
Twig.renderFile(path.join(__dirname, '/README_template.md'), data, (err, html) => {
if (err) {
console.log(err)
} else {
// Strip comments & write.
html = html.replace(/\n/gi, '')
fs.writeFileSync(directory + 'README.md', html)
}
})
}
logger.info('Register new domain: ' + domain);
if (process.env.ENVIRONMENT == 'DEVELOPMENT') {
console.log('Domain: ', domain);
console.log('Token: ', token);
} else {
let renderParams = {
domain: domain,
token: token,
serverUrl: process.env.SERVER_URL
};
Twig.renderFile('views/notifies/email/domain.twig', renderParams, function (err, html) {
if (err) {
logger.error('Can not render notify template because of ', err);
return;
}
email.init();
email.send(
res.locals.user.email,
'Integration token for ' + domain,
'',
html
);
files.forEach((item) => {
Twig.renderFile(path.join(__dirname, item.template), data, (err, twigOutput) => {
if (err) {
console.log(err)
} else {
fs.writeFileSync(directory + item.output, twigOutput)
}
})
})
.then(function ({insertedUser, password}) {
if (insertedUser) {
if (process.env.ENVIRONMENT == 'DEVELOPMENT') {
console.log('Your email: ', insertedUser.email);
console.log('Your password: ', password);
} else {
let renderParams = {
password: password,
settingsLink: process.env.SERVER_URL + '/garage/settings'
};
Twig.renderFile('views/notifies/email/join.twig', renderParams, function (err, html) {
if (err) {
logger.error('Can not render notify template because of ', err);
global.catchException(err);
return;
}
email.send(
insertedUser.email,
'Welcome to Hawk.so',
'',
html
);
});
}
res.redirect('/login?success=1&email=' + insertedUser.email);
.then(function (insertedProject) {
let renderParams = {
name: insertedProject.name,
token: insertedProject.token,
serverUrl: process.env.SERVER_URL
};
Twig.renderFile('views/notifies/email/project.twig', renderParams, function (err, html) {
if (err) {
logger.error('Can not render notify template because of ', err);
global.catchException(err);
return;
}
email.send(
res.locals.user.email,
'Integration token for ' + insertedProject.name,
'',
html
);
});
let message = insertedProject.name + ' was successfully added';
return new Promise((resolve, reject) => {
let templatePath = TemplateEngine.getTemplatePath(template, path);
this.logger.debug("Loading template path", {templatePath, data})
try {
renderFile(
templatePath,
data,
(error, html) => {
if (error) {
reject(error);
} else {
resolve(html);
}
}
);
} catch (e) {
reject(e);
}
});
}
users.forEach(function (userData) {
let userId = userData.userId.toString(),
renderParams = {
event: event,
project: project,
serverUrl: process.env.SERVER_URL,
times: times,
userData: userData,
unsubscribeHash: generateUnsubscribeHash(userId, project._id)
};
Twig.renderFile(templatesPath + templates.messenger, renderParams, function (err, html) {
if (err) {
logger.error('Can not render notify template because of ', err);
return;
}
/**
* Send Telegram notification
*/
if (userData.notifies.tg && userData.tgHook) {
request.post({
url: userData.tgHook,
form: {
message: html,
parse_mode: 'HTML'
}
}, (err, httpResponse, body) => {
let newMemberRequest = await project.addMember(foundProject._id, null, null, userEmail);
let inviteHash = project.generateInviteHash(newMemberRequest.insertedId, foundProject._id);
let inviteLink = process.env.SERVER_URL + '/invite'
+ '?member=' + newMemberRequest.insertedId
+ '&project=' + foundProject._id
+ '&hash=' + inviteHash;
let renderParams = {
project: foundProject,
inviteLink: inviteLink
};
Twig.renderFile('views/notifies/email/projectInvite.twig', renderParams, (err, html) => {
if (err) {
logger.error('Error while rendering email template %o' % err);
global.catchException(err);
return;
}
email.send(userEmail, 'Invitation to ' + foundProject.name, '', html);
});
res.json({
success: 1,
message: 'Invitation for ' + userEmail + ' was sent'
});
} catch (e) {
logger.error('Error while sending project invitation ', e);
global.catchException(e);