@yrpri/api 9.0.202 → 9.0.204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/controllers/groups.cjs
CHANGED
|
@@ -295,6 +295,7 @@ var updateGroupConfigParameters = function (req, group) {
|
|
|
295
295
|
group.set("configuration.hideNewestFromFilter", truthValueFromBody(req.body.hideNewestFromFilter));
|
|
296
296
|
group.set("configuration.hideGroupLevelTabs", truthValueFromBody(req.body.hideGroupLevelTabs));
|
|
297
297
|
group.set("configuration.hidePostFilterAndSearch", truthValueFromBody(req.body.hidePostFilterAndSearch));
|
|
298
|
+
group.set("configuration.categoryListView", truthValueFromBody(req.body.categoryListView));
|
|
298
299
|
group.set("configuration.hidePostImageUploads", truthValueFromBody(req.body.hidePostImageUploads));
|
|
299
300
|
group.set("configuration.hideNewPointOnNewIdea", truthValueFromBody(req.body.hideNewPointOnNewIdea));
|
|
300
301
|
group.set("configuration.maxDaysBackForRecommendations", req.body.maxDaysBackForRecommendations &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yrpri/api",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.204",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Bjarnason & Citizens Foundation",
|
|
6
6
|
"repository": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@google-cloud/vertexai": "^1.10.0",
|
|
26
26
|
"@google-cloud/vision": "^5.1.0",
|
|
27
27
|
"@node-saml/passport-saml": "^5.0.1",
|
|
28
|
-
"@policysynth/agents": "^1.3.
|
|
28
|
+
"@policysynth/agents": "^1.3.162",
|
|
29
29
|
"async": "^3.2.6",
|
|
30
30
|
"authorized": "^1.0.0",
|
|
31
31
|
"aws-sdk": "^2.1692.0",
|
|
@@ -108,6 +108,17 @@ const renderTemplateWithLocals = (templatePath, locals, done) => {
|
|
|
108
108
|
done(error, { html, text });
|
|
109
109
|
});
|
|
110
110
|
};
|
|
111
|
+
const renderTemplatePart = (templatePath, locals, part, done) => {
|
|
112
|
+
var fileName = part === "html" ? "html.ejs" : "text.ejs";
|
|
113
|
+
ejs.renderFile(path.join(templatePath, fileName), locals, {}, (err, rendered) => {
|
|
114
|
+
if (err) {
|
|
115
|
+
done(err);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
done(null, rendered);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
};
|
|
111
122
|
const translateSubject = function (subjectHash) {
|
|
112
123
|
if (typeof subjectHash === 'string') {
|
|
113
124
|
return i18n.t(subjectHash);
|
|
@@ -433,7 +444,44 @@ var sendOneEmail = function (emailLocals, callback) {
|
|
|
433
444
|
},
|
|
434
445
|
function (seriesCallback) {
|
|
435
446
|
log.info("EmailWorker Started Sending", { locale: i18n.language });
|
|
436
|
-
|
|
447
|
+
var hasRenderedHtml = emailLocals && typeof emailLocals.renderedHtml === "string";
|
|
448
|
+
var hasRenderedText = emailLocals && typeof emailLocals.renderedText === "string";
|
|
449
|
+
var usePreRendered = hasRenderedHtml || hasRenderedText;
|
|
450
|
+
var renderOrUse = function (done) {
|
|
451
|
+
if (!usePreRendered) {
|
|
452
|
+
return renderTemplateWithLocals(path.join(templatesDir, emailLocals.template), emailLocals, done);
|
|
453
|
+
}
|
|
454
|
+
var templatePath = emailLocals && emailLocals.template
|
|
455
|
+
? path.join(templatesDir, emailLocals.template)
|
|
456
|
+
: null;
|
|
457
|
+
if ((hasRenderedHtml && hasRenderedText) || !templatePath) {
|
|
458
|
+
return done(null, {
|
|
459
|
+
html: hasRenderedHtml ? emailLocals.renderedHtml : undefined,
|
|
460
|
+
text: hasRenderedText ? emailLocals.renderedText : undefined,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
if (hasRenderedHtml && !hasRenderedText) {
|
|
464
|
+
return renderTemplatePart(templatePath, emailLocals, "text", function (error, renderedText) {
|
|
465
|
+
if (error) {
|
|
466
|
+
return done(error);
|
|
467
|
+
}
|
|
468
|
+
return done(null, {
|
|
469
|
+
html: emailLocals.renderedHtml,
|
|
470
|
+
text: renderedText,
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
return renderTemplatePart(templatePath, emailLocals, "html", function (error, renderedHtml) {
|
|
475
|
+
if (error) {
|
|
476
|
+
return done(error);
|
|
477
|
+
}
|
|
478
|
+
return done(null, {
|
|
479
|
+
html: renderedHtml,
|
|
480
|
+
text: emailLocals.renderedText,
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
};
|
|
484
|
+
renderOrUse((error, results) => {
|
|
437
485
|
if (error) {
|
|
438
486
|
log.error("EmailWorker Error", {
|
|
439
487
|
err: error,
|
|
@@ -459,16 +507,21 @@ var sendOneEmail = function (emailLocals, callback) {
|
|
|
459
507
|
if (bcc === emailLocals.user.email) {
|
|
460
508
|
bcc = null;
|
|
461
509
|
}
|
|
462
|
-
|
|
510
|
+
var mailOptions = {
|
|
463
511
|
from: fromEmail,
|
|
464
512
|
sender: sender,
|
|
465
513
|
replyTo: replyTo,
|
|
466
514
|
to: emailLocals.user.email,
|
|
467
515
|
bcc: bcc,
|
|
468
516
|
subject: translatedSubject,
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
517
|
+
};
|
|
518
|
+
if (typeof results.html === "string") {
|
|
519
|
+
mailOptions.html = results.html;
|
|
520
|
+
}
|
|
521
|
+
if (typeof results.text === "string") {
|
|
522
|
+
mailOptions.text = results.text;
|
|
523
|
+
}
|
|
524
|
+
transport.sendMail(mailOptions, function (error, responseStatus) {
|
|
472
525
|
if (error) {
|
|
473
526
|
log.error("EmailWorker", {
|
|
474
527
|
errorHeaders: error.response
|
|
@@ -510,7 +563,7 @@ var sendOneEmail = function (emailLocals, callback) {
|
|
|
510
563
|
parseInt(Math.random() * (423432432432 - 1232) + 1232) +
|
|
511
564
|
".html";
|
|
512
565
|
fs.unlink(fileName, function (err) {
|
|
513
|
-
fs.writeFile(fileName, results.html, function (err) {
|
|
566
|
+
fs.writeFile(fileName, typeof results.html === "string" ? results.html : "", function (err) {
|
|
514
567
|
if (err) {
|
|
515
568
|
log.error(err);
|
|
516
569
|
}
|