@plusscommunities/pluss-core-aws 2.0.25-beta.2 → 2.0.25-beta.4

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.
@@ -19,7 +19,7 @@
19
19
 
20
20
  const AWS = require("aws-sdk");
21
21
  const moment = require("moment");
22
- const indexQuery = require("../db/common/indexQuery");
22
+ const indexQueryRecursive = require("../db/common/indexQueryRecursive");
23
23
  const updateRef = require("../db/common/updateRef");
24
24
  const editRef = require("../db/common/editRef");
25
25
 
@@ -41,6 +41,8 @@ const DEFAULT_PROTECTED_FIELDS = [
41
41
  "PublishedToSites", // HQ-only field; copies don't carry the multi-site list
42
42
  "UnsentNotification", // each copy's notification state is independent
43
43
  "Deleted", // cascadeHqRetract is the dedicated path; propagateHqEdit must not touch this
44
+ "UnixTimestamp", // per-copy fan-out timestamp; HQ-source MODIFY must not rewind copies' feed position
45
+ "UnixTimestampReverse", // ↳ paired with UnixTimestamp; same rationale (used as feed-sort key on community sites)
44
46
  ];
45
47
 
46
48
  // ---------------------------------------------------------------------------
@@ -94,12 +96,18 @@ const findCopiesByHqSourceId = async (
94
96
  if (!hqSourceId) {
95
97
  return [];
96
98
  }
97
- const result = await indexQuery(tableName, {
99
+ // indexQueryRecursive paginates LastEvaluatedKey internally and returns a
100
+ // flat array — required because a single GSI query response caps at 1 MiB
101
+ // and large-content HQ fan-outs to ~50 client sites can exceed that. With
102
+ // the non-recursive indexQuery, propagateHqEdit + cascadeHqRetract would
103
+ // silently miss copies on page 2+, leaving them stale after edits and
104
+ // visible after retractions.
105
+ const items = await indexQueryRecursive(tableName, {
98
106
  IndexName: indexName,
99
107
  KeyConditionExpression: "HqSourceId = :sid",
100
108
  ExpressionAttributeValues: { ":sid": hqSourceId },
101
109
  });
102
- return result?.Items || [];
110
+ return items || [];
103
111
  };
104
112
 
105
113
  /**
@@ -136,7 +144,14 @@ const fanOutHqSource = async (hqSourceRow, tableName) => {
136
144
  return [];
137
145
  }
138
146
  const copyId = `hqcopy-${hqSourceRow.Id}`;
139
- const now = moment.utc().unix();
147
+ // IMPORTANT: milliseconds (.valueOf), not seconds (.unix). Newsletter
148
+ // rows written by addNewsletterEntry.js use `moment.utc().valueOf()` for
149
+ // UnixTimestamp. UnixTimestampReverse-keyed feed queries (the standard
150
+ // Pluss list pattern) would otherwise rank HQ copies ~1000× ahead of
151
+ // locally-authored posts forever — MAX_SAFE_INTEGER minus a number 10^9
152
+ // is vastly larger than MAX_SAFE_INTEGER minus 10^12. Keep parity with
153
+ // the canonical addNewsletterEntry convention.
154
+ const now = moment.utc().valueOf();
140
155
 
141
156
  const writes = targets.map((targetSiteId) => {
142
157
  // Spread + override pattern: keep all content fields, swap identity
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-core-aws",
3
- "version": "2.0.25-beta.2",
3
+ "version": "2.0.25-beta.4",
4
4
  "description": "Core extension package for Pluss Communities platform",
5
5
  "scripts": {
6
6
  "betapatch": "npm version prepatch --preid=beta",