@yrpri/api 9.0.179 → 9.0.181
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
|
@@ -995,9 +995,7 @@ router.post("/:groupId/sendEmailInvitesForAnons", auth.can("edit group"), async
|
|
|
995
995
|
});
|
|
996
996
|
return;
|
|
997
997
|
}
|
|
998
|
-
const emailArray = emails
|
|
999
|
-
.split("\n")
|
|
1000
|
-
.map((email) => email.trim());
|
|
998
|
+
const emailArray = emails.split("\n").map((email) => email.trim());
|
|
1001
999
|
// Validate each email
|
|
1002
1000
|
const validEmails = emailArray.filter((email) => {
|
|
1003
1001
|
// Basic email validation regex
|
|
@@ -2518,7 +2516,9 @@ router.post("/:id/clone", auth.can("edit group"), function (req, res) {
|
|
|
2518
2516
|
res.send({ id: newGroup.id });
|
|
2519
2517
|
}
|
|
2520
2518
|
else {
|
|
2521
|
-
log.error("Group Cloned succeeded but newGroup is missing", {
|
|
2519
|
+
log.error("Group Cloned succeeded but newGroup is missing", {
|
|
2520
|
+
groupId: req.params.id,
|
|
2521
|
+
});
|
|
2522
2522
|
res.sendStatus(500);
|
|
2523
2523
|
}
|
|
2524
2524
|
});
|
|
@@ -2531,72 +2531,95 @@ router.post("/:id/clone", auth.can("edit group"), function (req, res) {
|
|
|
2531
2531
|
sendGroupOrError(res, null, "delete", req.user, error);
|
|
2532
2532
|
});
|
|
2533
2533
|
});
|
|
2534
|
-
router.post("/:id/cloneToCommunity/:communityId", auth.can("edit group"),
|
|
2535
|
-
models.
|
|
2534
|
+
router.post("/:id/cloneToCommunity/:communityId", auth.can("edit group"), function (req, res) {
|
|
2535
|
+
models.Community.findOne({
|
|
2536
2536
|
attributes: ["id"],
|
|
2537
|
-
where: { id: req.params.
|
|
2537
|
+
where: { id: req.params.communityId },
|
|
2538
2538
|
})
|
|
2539
|
-
.then(function (
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2539
|
+
.then(function (community) {
|
|
2540
|
+
community
|
|
2541
|
+
.hasCommunityAdmins(req.user)
|
|
2542
|
+
.then(function (isAdmin) {
|
|
2543
|
+
if (isAdmin) {
|
|
2544
|
+
models.Group.findOne({
|
|
2545
|
+
attributes: ["id"],
|
|
2546
|
+
where: { id: req.params.id },
|
|
2547
|
+
})
|
|
2548
|
+
.then(function (group) {
|
|
2549
|
+
if (group) {
|
|
2550
|
+
models.Community.findOne({
|
|
2551
|
+
where: { id: req.params.communityId },
|
|
2552
|
+
attributes: ["id", "domain_id"],
|
|
2553
|
+
include: [
|
|
2554
|
+
{
|
|
2555
|
+
model: models.Domain,
|
|
2556
|
+
attributes: ["id"],
|
|
2557
|
+
},
|
|
2558
|
+
],
|
|
2559
|
+
})
|
|
2560
|
+
.then(function (community) {
|
|
2561
|
+
if (community) {
|
|
2562
|
+
community
|
|
2563
|
+
.hasCommunityAdmins(req.user)
|
|
2564
|
+
.then(function (isAdmin) {
|
|
2565
|
+
if (isAdmin) {
|
|
2566
|
+
copyGroup(group.id, community, community.domain_id, { skipUsers: true, skipActivities: true }, (error, newGroup) => {
|
|
2567
|
+
if (error) {
|
|
2568
|
+
log.error("Group Clone To Community Failed", {
|
|
2569
|
+
error,
|
|
2570
|
+
groupId: req.params.id,
|
|
2571
|
+
communityId: req.params.communityId,
|
|
2572
|
+
});
|
|
2573
|
+
res.sendStatus(500);
|
|
2574
|
+
}
|
|
2575
|
+
else if (newGroup) {
|
|
2576
|
+
log.info("Group Cloned To Community", {
|
|
2577
|
+
groupId: req.params.id,
|
|
2578
|
+
newGroupId: newGroup.id,
|
|
2579
|
+
communityId: req.params.communityId,
|
|
2580
|
+
});
|
|
2581
|
+
res.send({ id: newGroup.id });
|
|
2582
|
+
}
|
|
2583
|
+
else {
|
|
2584
|
+
log.error("Group Clone To Community succeeded but newGroup is missing", {
|
|
2585
|
+
groupId: req.params.id,
|
|
2586
|
+
communityId: req.params.communityId,
|
|
2587
|
+
});
|
|
2588
|
+
res.sendStatus(500);
|
|
2589
|
+
}
|
|
2590
|
+
});
|
|
2591
|
+
}
|
|
2592
|
+
else {
|
|
2593
|
+
sendGroupOrError(res, null, "cloneToCommunity", req.user, "Not community admin", 401);
|
|
2594
|
+
}
|
|
2595
|
+
});
|
|
2596
|
+
}
|
|
2597
|
+
else {
|
|
2598
|
+
sendGroupOrError(res, req.params.communityId, "cloneToCommunity", req.user, "Not found", 404);
|
|
2599
|
+
}
|
|
2600
|
+
})
|
|
2601
|
+
.catch(function (error) {
|
|
2602
|
+
sendGroupOrError(res, null, "cloneToCommunity", req.user, error);
|
|
2603
|
+
});
|
|
2604
|
+
}
|
|
2605
|
+
else {
|
|
2606
|
+
sendGroupOrError(res, req.params.id, "cloneToCommunity", req.user, "Not found", 404);
|
|
2607
|
+
}
|
|
2608
|
+
})
|
|
2609
|
+
.catch(function (error) {
|
|
2610
|
+
sendGroupOrError(res, null, "cloneToCommunity", req.user, error);
|
|
2611
|
+
});
|
|
2612
|
+
}
|
|
2613
|
+
else {
|
|
2614
|
+
sendGroupOrError(res, null, "delete", req.user, "Not authorized");
|
|
2615
|
+
}
|
|
2616
|
+
})
|
|
2617
|
+
.catch(function (error) {
|
|
2618
|
+
sendGroupOrError(res, null, "delete", req.user, error);
|
|
2619
|
+
});
|
|
2597
2620
|
})
|
|
2598
2621
|
.catch(function (error) {
|
|
2599
|
-
sendGroupOrError(res, null, "
|
|
2622
|
+
sendGroupOrError(res, null, "delete", req.user, error);
|
|
2600
2623
|
});
|
|
2601
2624
|
});
|
|
2602
2625
|
router.get("/:id/checkNonOpenPosts", auth.can("view group"), (req, res) => {
|
|
@@ -4164,10 +4187,10 @@ router.get("/:domainId/getTemplates", auth.can("view domain"), async (req, res)
|
|
|
4164
4187
|
// public templates
|
|
4165
4188
|
{ access: models.Group.ACCESS_PUBLIC },
|
|
4166
4189
|
// templates where user is an admin
|
|
4167
|
-
literal(`"GroupAdmins"."id" IS NOT NULL`)
|
|
4168
|
-
]
|
|
4169
|
-
}
|
|
4170
|
-
]
|
|
4190
|
+
literal(`"GroupAdmins"."id" IS NOT NULL`),
|
|
4191
|
+
],
|
|
4192
|
+
},
|
|
4193
|
+
],
|
|
4171
4194
|
},
|
|
4172
4195
|
include: [
|
|
4173
4196
|
{
|
|
@@ -4188,14 +4211,14 @@ router.get("/:domainId/getTemplates", auth.can("view domain"), async (req, res)
|
|
|
4188
4211
|
model: models.Domain,
|
|
4189
4212
|
attributes: ["id", "name"],
|
|
4190
4213
|
required: true,
|
|
4191
|
-
where: { id: domainId }
|
|
4214
|
+
where: { id: domainId },
|
|
4192
4215
|
},
|
|
4193
4216
|
],
|
|
4194
|
-
}
|
|
4217
|
+
},
|
|
4195
4218
|
],
|
|
4196
4219
|
attributes: ["id", "name"],
|
|
4197
4220
|
distinct: true,
|
|
4198
|
-
order: [["name", "ASC"]]
|
|
4221
|
+
order: [["name", "ASC"]],
|
|
4199
4222
|
});
|
|
4200
4223
|
res.send(templateGroups || []);
|
|
4201
4224
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yrpri/api",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.181",
|
|
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.149",
|
|
29
29
|
"async": "^3.2.6",
|
|
30
30
|
"authorized": "^1.0.0",
|
|
31
31
|
"aws-sdk": "^2.1692.0",
|
|
@@ -258,7 +258,7 @@ i18n
|
|
|
258
258
|
// this is the defaults
|
|
259
259
|
backend: {
|
|
260
260
|
// path where resources get loaded from
|
|
261
|
-
loadPath:
|
|
261
|
+
loadPath: localesPath + '/{{lng}}/translation.json',
|
|
262
262
|
// path to post missing resources
|
|
263
263
|
addPath: localesPath + '/{{lng}}/translation.missing.json',
|
|
264
264
|
// jsonIndent to use when storing json files
|
|
@@ -456,7 +456,7 @@ i18n
|
|
|
456
456
|
// this is the defaults
|
|
457
457
|
backend: {
|
|
458
458
|
// path where resources get loaded from
|
|
459
|
-
loadPath:
|
|
459
|
+
loadPath: localesPath + '/{{lng}}/translation.json',
|
|
460
460
|
// path to post missing resources
|
|
461
461
|
addPath: localesPath + '/{{lng}}/translation.missing.json',
|
|
462
462
|
// jsonIndent to use when storing json files
|
|
@@ -30,7 +30,7 @@ i18n
|
|
|
30
30
|
// this is the defaults
|
|
31
31
|
backend: {
|
|
32
32
|
// path where resources get loaded from
|
|
33
|
-
loadPath:
|
|
33
|
+
loadPath: localesPath + '/{{lng}}/translation.json',
|
|
34
34
|
// path to post missing resources
|
|
35
35
|
addPath: localesPath + '/{{lng}}/translation.missing.json',
|
|
36
36
|
// jsonIndent to use when storing json files
|
package/utils/i18n.cjs
CHANGED
|
@@ -1,29 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var i18n = require('i18next');
|
|
3
3
|
var Backend = require('i18next-fs-backend');
|
|
4
|
-
var path = require('path');
|
|
5
|
-
var fs = require('fs');
|
|
6
|
-
function buildLoadPath(language, namespace) {
|
|
7
|
-
var localesDir = path.resolve(__dirname, '../services/locales');
|
|
8
|
-
var filePath = path.join(localesDir, language, 'translation.json');
|
|
9
|
-
if (!fs.existsSync(filePath)) {
|
|
10
|
-
var altLanguage = language.replace(/-/g, '_');
|
|
11
|
-
filePath = path.join(localesDir, altLanguage, 'translation.json');
|
|
12
|
-
if (!fs.existsSync(filePath)) {
|
|
13
|
-
filePath = path.join(localesDir, 'en', 'translation.json');
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return filePath;
|
|
17
|
-
}
|
|
18
4
|
i18n
|
|
19
5
|
.use(Backend)
|
|
20
6
|
.init({
|
|
21
|
-
fallbackLng: 'en',
|
|
22
|
-
lowerCaseLng: true,
|
|
23
7
|
// this is the defaults
|
|
24
8
|
backend: {
|
|
25
9
|
// path where resources get loaded from
|
|
26
|
-
loadPath:
|
|
10
|
+
loadPath: '../locales/{{lng}}/translation.json',
|
|
27
11
|
// path to post missing resources
|
|
28
12
|
addPath: '../locales/{{lng}}/translation.missing.json',
|
|
29
13
|
// jsonIndent to use when storing json files
|
|
@@ -31,4 +15,3 @@ i18n
|
|
|
31
15
|
}
|
|
32
16
|
});
|
|
33
17
|
module.exports = i18n;
|
|
34
|
-
module.exports.buildLoadPath = buildLoadPath;
|