@yrpri/api 9.0.178 → 9.0.180

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/app.js CHANGED
@@ -560,8 +560,8 @@ export class YourPrioritiesApi {
560
560
  this.app.use(this.setupExpresLogger);
561
561
  this.app.use(useragent.express());
562
562
  this.app.use(requestIp.mw());
563
- this.app.use(bodyParser.json({ limit: "100mb", strict: false }));
564
- this.app.use(bodyParser.urlencoded({ limit: "100mb", extended: true }));
563
+ this.app.use(bodyParser.json({ limit: "150mb", strict: false }));
564
+ this.app.use(bodyParser.urlencoded({ limit: "150mb", extended: true }));
565
565
  if (process.env.ALLOWED_ORIGINS) {
566
566
  this.app.use(cors({
567
567
  origin: process.env.ALLOWED_ORIGINS.split(","),
@@ -783,6 +783,7 @@ const updateCommunityConfigParameters = function (req, community) {
783
783
  community.set("configuration.hideLogoBoxShadow", truthValueFromBody(req.body.hideLogoBoxShadow));
784
784
  community.set("configuration.muteNotificationsForEndorsements", truthValueFromBody(req.body.muteNotificationsForEndorsements));
785
785
  community.set("configuration.useTextOnlyInfoBox", truthValueFromBody(req.body.useTextOnlyInfoBox));
786
+ community.set("configuration.useInfoIconInsteadOfHelpIcon", truthValueFromBody(req.body.useInfoIconInsteadOfHelpIcon));
786
787
  const ltpConfigText = req.body.ltp && req.body.ltp != "" ? req.body.ltp : null;
787
788
  if (ltpConfigText) {
788
789
  try {
@@ -191,6 +191,7 @@ var updateGroupConfigParameters = function (req, group) {
191
191
  group.set("configuration.hideNewPostOnPostPage", truthValueFromBody(req.body.hideNewPostOnPostPage));
192
192
  group.set("configuration.newPointOptional", truthValueFromBody(req.body.newPointOptional));
193
193
  group.set("configuration.hideHelpIcon", truthValueFromBody(req.body.hideHelpIcon));
194
+ group.set("configuration.useInfoIconInsteadOfHelpIcon", truthValueFromBody(req.body.useInfoIconInsteadOfHelpIcon));
194
195
  group.set("configuration.hideEmoji", truthValueFromBody(req.body.hideEmoji));
195
196
  group.set("configuration.hideGroupHeader", truthValueFromBody(req.body.hideGroupHeader));
196
197
  group.set("configuration.hidePointAuthor", truthValueFromBody(req.body.hidePointAuthor));
@@ -994,9 +995,7 @@ router.post("/:groupId/sendEmailInvitesForAnons", auth.can("edit group"), async
994
995
  });
995
996
  return;
996
997
  }
997
- const emailArray = emails
998
- .split("\n")
999
- .map((email) => email.trim());
998
+ const emailArray = emails.split("\n").map((email) => email.trim());
1000
999
  // Validate each email
1001
1000
  const validEmails = emailArray.filter((email) => {
1002
1001
  // Basic email validation regex
@@ -2517,7 +2516,9 @@ router.post("/:id/clone", auth.can("edit group"), function (req, res) {
2517
2516
  res.send({ id: newGroup.id });
2518
2517
  }
2519
2518
  else {
2520
- log.error("Group Cloned succeeded but newGroup is missing", { groupId: req.params.id });
2519
+ log.error("Group Cloned succeeded but newGroup is missing", {
2520
+ groupId: req.params.id,
2521
+ });
2521
2522
  res.sendStatus(500);
2522
2523
  }
2523
2524
  });
@@ -2530,6 +2531,97 @@ router.post("/:id/clone", auth.can("edit group"), function (req, res) {
2530
2531
  sendGroupOrError(res, null, "delete", req.user, error);
2531
2532
  });
2532
2533
  });
2534
+ router.post("/:id/cloneToCommunity/:communityId", auth.can("edit group"), function (req, res) {
2535
+ models.Community.findOne({
2536
+ attributes: ["id"],
2537
+ where: { id: req.params.communityId },
2538
+ })
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
+ });
2620
+ })
2621
+ .catch(function (error) {
2622
+ sendGroupOrError(res, null, "delete", req.user, error);
2623
+ });
2624
+ });
2533
2625
  router.get("/:id/checkNonOpenPosts", auth.can("view group"), (req, res) => {
2534
2626
  var PostsByNotOpen = models.Post.scope("not_open");
2535
2627
  PostsByNotOpen.count({ where: { group_id: req.params.id } })
@@ -4095,10 +4187,10 @@ router.get("/:domainId/getTemplates", auth.can("view domain"), async (req, res)
4095
4187
  // public templates
4096
4188
  { access: models.Group.ACCESS_PUBLIC },
4097
4189
  // templates where user is an admin
4098
- literal(`"GroupAdmins"."id" IS NOT NULL`)
4099
- ]
4100
- }
4101
- ]
4190
+ literal(`"GroupAdmins"."id" IS NOT NULL`),
4191
+ ],
4192
+ },
4193
+ ],
4102
4194
  },
4103
4195
  include: [
4104
4196
  {
@@ -4119,14 +4211,14 @@ router.get("/:domainId/getTemplates", auth.can("view domain"), async (req, res)
4119
4211
  model: models.Domain,
4120
4212
  attributes: ["id", "name"],
4121
4213
  required: true,
4122
- where: { id: domainId }
4214
+ where: { id: domainId },
4123
4215
  },
4124
4216
  ],
4125
- }
4217
+ },
4126
4218
  ],
4127
4219
  attributes: ["id", "name"],
4128
4220
  distinct: true,
4129
- order: [["name", "ASC"]]
4221
+ order: [["name", "ASC"]],
4130
4222
  });
4131
4223
  res.send(templateGroups || []);
4132
4224
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yrpri/api",
3
- "version": "9.0.178",
3
+ "version": "9.0.180",
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.145",
28
+ "@policysynth/agents": "^1.3.148",
29
29
  "async": "^3.2.6",
30
30
  "authorized": "^1.0.0",
31
31
  "aws-sdk": "^2.1692.0",