@pkcprotocol/pkc-js 0.0.156 → 0.0.158

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.
Files changed (122) hide show
  1. package/README.md +55 -3
  2. package/dist/browser/clients/base-client-manager.js +10 -1
  3. package/dist/browser/clients/base-client-manager.js.map +1 -1
  4. package/dist/browser/clients/rpc-client/schema.d.ts +1 -0
  5. package/dist/browser/clients/shared-pubsub-topic-list.d.ts +14 -0
  6. package/dist/browser/clients/shared-pubsub-topic-list.js +61 -0
  7. package/dist/browser/clients/shared-pubsub-topic-list.js.map +1 -0
  8. package/dist/browser/community/schema.d.ts +13 -0
  9. package/dist/browser/generated-version.d.ts +1 -1
  10. package/dist/browser/generated-version.js +1 -1
  11. package/dist/browser/index-with-compile-cache.d.ts +2 -0
  12. package/dist/browser/index.d.ts +4 -0
  13. package/dist/browser/pages/schema.d.ts +3 -0
  14. package/dist/browser/publications/comment/comment.d.ts +1 -0
  15. package/dist/browser/publications/comment/comment.js +1 -0
  16. package/dist/browser/publications/comment/comment.js.map +1 -1
  17. package/dist/browser/publications/comment/schema.d.ts +4 -2
  18. package/dist/browser/publications/comment/schema.js +2 -0
  19. package/dist/browser/publications/comment/schema.js.map +1 -1
  20. package/dist/browser/publications/comment-moderation/schema.js +2 -2
  21. package/dist/browser/publications/comment-moderation/schema.js.map +1 -1
  22. package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +2 -0
  23. package/dist/browser/rpc/src/schema.d.ts +12 -0
  24. package/dist/browser/runtime/node/community/db-handler.d.ts +3 -0
  25. package/dist/browser/runtime/node/community/db-handler.js +51 -14
  26. package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
  27. package/dist/browser/runtime/node/community/local-community/cleanup.js +6 -0
  28. package/dist/browser/runtime/node/community/local-community/cleanup.js.map +1 -1
  29. package/dist/browser/runtime/node/community/local-community/ipns-publishing.d.ts +6 -0
  30. package/dist/browser/runtime/node/community/local-community/ipns-publishing.js +85 -12
  31. package/dist/browser/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
  32. package/dist/browser/runtime/node/community/local-community/lifecycle.js +102 -61
  33. package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
  34. package/dist/browser/runtime/node/community/local-community/post-updates-bucket.d.ts +21 -0
  35. package/dist/browser/runtime/node/community/local-community/post-updates-bucket.js +141 -4
  36. package/dist/browser/runtime/node/community/local-community/post-updates-bucket.js.map +1 -1
  37. package/dist/browser/runtime/node/community/local-community/pubsub.js +11 -4
  38. package/dist/browser/runtime/node/community/local-community/pubsub.js.map +1 -1
  39. package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.d.ts +22 -4
  40. package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js +45 -9
  41. package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
  42. package/dist/browser/runtime/node/community/local-community.d.ts +4 -0
  43. package/dist/browser/runtime/node/community/local-community.js +16 -0
  44. package/dist/browser/runtime/node/community/local-community.js.map +1 -1
  45. package/dist/browser/runtime/node/event-loop-watch.d.ts +13 -0
  46. package/dist/browser/runtime/node/event-loop-watch.js +58 -0
  47. package/dist/browser/runtime/node/event-loop-watch.js.map +1 -0
  48. package/dist/browser/schema/schema-util.d.ts +5 -0
  49. package/dist/browser/schema/schema.d.ts +9 -0
  50. package/dist/browser/schema/schema.js +9 -1
  51. package/dist/browser/schema/schema.js.map +1 -1
  52. package/dist/browser/schema.d.ts +16 -0
  53. package/dist/browser/test/test-util.d.ts +5 -0
  54. package/dist/browser/version.js +1 -1
  55. package/dist/bundled/bundle-manifest.json +43 -40
  56. package/dist/bundled/challenges.js +1 -1
  57. package/dist/bundled/chunks/{helia-for-pkc-CceaAEzV.js → helia-for-pkc-D3uvabO4.js} +2 -2
  58. package/dist/bundled/chunks/{local-community-C8Qwak8F.js → local-community-ChB5dbEH.js} +1 -1
  59. package/dist/bundled/chunks/{local-community-BzZbcwm-.js → local-community-SgssDrxj.js} +416 -90
  60. package/dist/bundled/chunks/{node-CleFjKjX.js → node-Bx3xTqFv.js} +6 -5
  61. package/dist/bundled/chunks/{page-sort-scoring-BAl6dNeR.js → page-sort-scoring-CZmdHvps.js} +1 -1
  62. package/dist/bundled/chunks/{rpc-local-community-CW6GnMsd.js → rpc-local-community-D66Be62U.js} +51 -4
  63. package/dist/bundled/chunks/{util-C0MpIK71.js → util-BuTE1Bd1.js} +7 -8
  64. package/dist/bundled/chunks/{util-C29b1mlK.js → util-CodXreIl.js} +1 -1
  65. package/dist/bundled/chunks/{validate-package-factories-CAwF_8n6.js → validate-package-factories-Bc4uoozL.js} +2 -2
  66. package/dist/bundled/index.js +1 -1
  67. package/dist/bundled/page-sorts.js +1 -1
  68. package/dist/bundled/rpc/src/index.js +4 -4
  69. package/dist/node/clients/base-client-manager.js +10 -1
  70. package/dist/node/clients/base-client-manager.js.map +1 -1
  71. package/dist/node/clients/rpc-client/schema.d.ts +1 -0
  72. package/dist/node/clients/shared-pubsub-topic-list.d.ts +14 -0
  73. package/dist/node/clients/shared-pubsub-topic-list.js +61 -0
  74. package/dist/node/clients/shared-pubsub-topic-list.js.map +1 -0
  75. package/dist/node/community/schema.d.ts +13 -0
  76. package/dist/node/generated-version.d.ts +1 -1
  77. package/dist/node/generated-version.js +1 -1
  78. package/dist/node/index-with-compile-cache.d.ts +2 -0
  79. package/dist/node/index.d.ts +4 -0
  80. package/dist/node/pages/schema.d.ts +3 -0
  81. package/dist/node/publications/comment/comment.d.ts +1 -0
  82. package/dist/node/publications/comment/comment.js +1 -0
  83. package/dist/node/publications/comment/comment.js.map +1 -1
  84. package/dist/node/publications/comment/schema.d.ts +4 -2
  85. package/dist/node/publications/comment/schema.js +2 -0
  86. package/dist/node/publications/comment/schema.js.map +1 -1
  87. package/dist/node/publications/comment-moderation/schema.js +2 -2
  88. package/dist/node/publications/comment-moderation/schema.js.map +1 -1
  89. package/dist/node/rpc/src/lib/pkc-js/index.d.ts +2 -0
  90. package/dist/node/rpc/src/schema.d.ts +12 -0
  91. package/dist/node/runtime/node/community/db-handler.d.ts +3 -0
  92. package/dist/node/runtime/node/community/db-handler.js +51 -14
  93. package/dist/node/runtime/node/community/db-handler.js.map +1 -1
  94. package/dist/node/runtime/node/community/local-community/cleanup.js +6 -0
  95. package/dist/node/runtime/node/community/local-community/cleanup.js.map +1 -1
  96. package/dist/node/runtime/node/community/local-community/ipns-publishing.d.ts +6 -0
  97. package/dist/node/runtime/node/community/local-community/ipns-publishing.js +85 -12
  98. package/dist/node/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
  99. package/dist/node/runtime/node/community/local-community/lifecycle.js +102 -61
  100. package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
  101. package/dist/node/runtime/node/community/local-community/post-updates-bucket.d.ts +21 -0
  102. package/dist/node/runtime/node/community/local-community/post-updates-bucket.js +141 -4
  103. package/dist/node/runtime/node/community/local-community/post-updates-bucket.js.map +1 -1
  104. package/dist/node/runtime/node/community/local-community/pubsub.js +11 -4
  105. package/dist/node/runtime/node/community/local-community/pubsub.js.map +1 -1
  106. package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.d.ts +22 -4
  107. package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js +45 -9
  108. package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
  109. package/dist/node/runtime/node/community/local-community.d.ts +4 -0
  110. package/dist/node/runtime/node/community/local-community.js +16 -0
  111. package/dist/node/runtime/node/community/local-community.js.map +1 -1
  112. package/dist/node/runtime/node/event-loop-watch.d.ts +13 -0
  113. package/dist/node/runtime/node/event-loop-watch.js +58 -0
  114. package/dist/node/runtime/node/event-loop-watch.js.map +1 -0
  115. package/dist/node/schema/schema-util.d.ts +5 -0
  116. package/dist/node/schema/schema.d.ts +9 -0
  117. package/dist/node/schema/schema.js +9 -1
  118. package/dist/node/schema/schema.js.map +1 -1
  119. package/dist/node/schema.d.ts +16 -0
  120. package/dist/node/test/test-util.d.ts +5 -0
  121. package/dist/node/version.js +1 -1
  122. package/package.json +1 -1
@@ -43,6 +43,12 @@ const TABLES = Object.freeze({
43
43
  PSEUDONYMITY_ALIASES: "pseudonymityAliases"
44
44
  });
45
45
  // The address an alias row's original public key derives to, or null when the key is malformed (kept, never looked up)
46
+ // A moderation's `author` that sets the author's ban: a positive timestamp, future (a ban) or past (an unban).
47
+ // A 0 only removes the mark from the comment it was published on (commentUpdate.authorBanExpiresAt), so the author
48
+ // aggregate skips it and falls through to the newest row that does carry a timestamp (issue #363).
49
+ function isAuthorBanRow(modEdit) {
50
+ return typeof modEdit?.banExpiresAt === "number" && modEdit.banExpiresAt > 0;
51
+ }
46
52
  function deriveAliasOriginalAuthorSignerAddress(originalAuthorPublicKey) {
47
53
  try {
48
54
  return getPKCAddressFromPublicKeySync(originalAuthorPublicKey);
@@ -52,11 +58,21 @@ function deriveAliasOriginalAuthorSignerAddress(originalAuthorPublicKey) {
52
58
  }
53
59
  }
54
60
  export class DbHandler {
61
+ // Every method that writes a publication (a vote, comment, edit, moderation, an approval, a purge) calls this.
62
+ // Besides dropping what was memoized from the old rows, it asks the community for a new record, which wakes its
63
+ // publish loop: the loop does not poll the DB for changes (issue #576). A write inside readBackWithoutStoring is
64
+ // rolled back, so it still drops the memo (the rows did change for the read that follows) but asks for no record.
65
+ _notePublicationWrite() {
66
+ this._publicationWriteGeneration++;
67
+ if (this._community && this._readBackWithoutStoringDepth === 0)
68
+ this._community._communityUpdateTrigger = true;
69
+ }
55
70
  constructor(community) {
56
71
  this._transactionGeneration = 0;
57
72
  // Advanced by every write to the publication tables (comments, votes, edits, moderations, aliases, purges). The
58
73
  // update cycle's author memo (CommunityAuthorMemo) is only reused while it stays the same.
59
74
  this._publicationWriteGeneration = 0;
75
+ this._readBackWithoutStoringDepth = 0;
60
76
  // The address this handler has claimed the start of, from lockCommunityStart until unlockCommunityStart
61
77
  this._startLockAddress = undefined;
62
78
  this._community = community;
@@ -237,11 +253,15 @@ export class DbHandler {
237
253
  // no transaction open (issue #417).
238
254
  readBackWithoutStoring(opts) {
239
255
  this._db.exec("SAVEPOINT read_back_without_storing");
256
+ this._readBackWithoutStoringDepth++;
240
257
  try {
241
258
  opts.write();
242
259
  return opts.read();
243
260
  }
244
261
  finally {
262
+ this._readBackWithoutStoringDepth--;
263
+ // what was memoized inside the savepoint was read from rows that are about to be gone
264
+ this._publicationWriteGeneration++;
245
265
  this._db.exec("ROLLBACK TO read_back_without_storing");
246
266
  this._db.exec("RELEASE read_back_without_storing");
247
267
  }
@@ -351,6 +371,7 @@ export class DbHandler {
351
371
  removed INTEGER NULLABLE, -- BOOLEAN (0/1)
352
372
  approved INTEGER NULLABLE, -- BOOLEAN (0/1)
353
373
  reason TEXT NULLABLE,
374
+ authorBanExpiresAt INTEGER NULLABLE, -- the ban a mod published on this comment (issue #363)
354
375
  updatedAt INTEGER NOT NULL CHECK(updatedAt > 0),
355
376
  protocolVersion TEXT NOT NULL,
356
377
  signature TEXT NOT NULL, -- JSON
@@ -1023,18 +1044,18 @@ export class DbHandler {
1023
1044
  }
1024
1045
  }
1025
1046
  deleteVote(authorSignerAddress, commentCid) {
1026
- this._publicationWriteGeneration++;
1047
+ this._notePublicationWrite();
1027
1048
  this._db
1028
1049
  .prepare(`DELETE FROM ${TABLES.VOTES} WHERE commentCid = ? AND authorSignerAddress = ?`)
1029
1050
  .run(commentCid, authorSignerAddress);
1030
1051
  }
1031
1052
  _deleteCommentEditRow(rowid) {
1032
- this._publicationWriteGeneration++;
1053
+ this._notePublicationWrite();
1033
1054
  const deleteResult = this._db.prepare(`DELETE FROM ${TABLES.COMMENT_EDITS} WHERE rowid = ?`).run(rowid);
1034
1055
  return deleteResult.changes > 0;
1035
1056
  }
1036
1057
  insertVotes(votes) {
1037
- this._publicationWriteGeneration++;
1058
+ this._notePublicationWrite();
1038
1059
  if (votes.length === 0)
1039
1060
  return;
1040
1061
  const processedVotes = this._processRecordsForDbBeforeInsert(votes);
@@ -1062,7 +1083,7 @@ export class DbHandler {
1062
1083
  insertMany(processedVotes);
1063
1084
  }
1064
1085
  insertComments(comments) {
1065
- this._publicationWriteGeneration++;
1086
+ this._notePublicationWrite();
1066
1087
  if (comments.length === 0)
1067
1088
  return;
1068
1089
  const processedComments = this._processRecordsForDbBeforeInsert(comments);
@@ -1087,7 +1108,7 @@ export class DbHandler {
1087
1108
  insertMany(processedComments);
1088
1109
  }
1089
1110
  insertPseudonymityAliases(aliases) {
1090
- this._publicationWriteGeneration++;
1111
+ this._notePublicationWrite();
1091
1112
  if (aliases.length === 0)
1092
1113
  return;
1093
1114
  const processedAliases = this._processRecordsForDbBeforeInsert(aliases).map((alias) => ({
@@ -1111,14 +1132,14 @@ export class DbHandler {
1111
1132
  const columnNames = this._getColumnNames(TABLES.COMMENT_UPDATES);
1112
1133
  const stmt = this._prepareCached(`
1113
1134
  INSERT INTO ${TABLES.COMMENT_UPDATES}
1114
- (cid, edit, upvoteCount, downvoteCount, replyCount, childCount, number, postNumber, flairs, spoiler, nsfw, pinned, locked, archived, removed, approved, reason, updatedAt, protocolVersion, signature, author, replies, lastChildCid, lastReplyTimestamp, postUpdatesBucket, publishedToPostUpdatesMFS, insertedAt, extraProps)
1115
- VALUES (@cid, @edit, @upvoteCount, @downvoteCount, @replyCount, @childCount, @number, @postNumber, @flairs, @spoiler, @nsfw, @pinned, @locked, @archived, @removed, @approved, @reason, @updatedAt, @protocolVersion, @signature, @author, @replies, @lastChildCid, @lastReplyTimestamp, @postUpdatesBucket, @publishedToPostUpdatesMFS, @insertedAt, @extraProps)
1135
+ (cid, edit, upvoteCount, downvoteCount, replyCount, childCount, number, postNumber, flairs, spoiler, nsfw, pinned, locked, archived, removed, approved, reason, authorBanExpiresAt, updatedAt, protocolVersion, signature, author, replies, lastChildCid, lastReplyTimestamp, postUpdatesBucket, publishedToPostUpdatesMFS, insertedAt, extraProps)
1136
+ VALUES (@cid, @edit, @upvoteCount, @downvoteCount, @replyCount, @childCount, @number, @postNumber, @flairs, @spoiler, @nsfw, @pinned, @locked, @archived, @removed, @approved, @reason, @authorBanExpiresAt, @updatedAt, @protocolVersion, @signature, @author, @replies, @lastChildCid, @lastReplyTimestamp, @postUpdatesBucket, @publishedToPostUpdatesMFS, @insertedAt, @extraProps)
1116
1137
  ON CONFLICT(cid) DO UPDATE SET
1117
1138
  edit = excluded.edit, upvoteCount = excluded.upvoteCount, downvoteCount = excluded.downvoteCount, replyCount = excluded.replyCount, childCount = excluded.childCount,
1118
1139
  number = COALESCE(excluded.number, ${TABLES.COMMENT_UPDATES}.number),
1119
1140
  postNumber = COALESCE(excluded.postNumber, ${TABLES.COMMENT_UPDATES}.postNumber),
1120
1141
  flairs = excluded.flairs, spoiler = excluded.spoiler, nsfw = excluded.nsfw, pinned = excluded.pinned, locked = excluded.locked, archived = excluded.archived,
1121
- removed = excluded.removed, approved = excluded.approved, reason = excluded.reason, updatedAt = excluded.updatedAt, protocolVersion = excluded.protocolVersion,
1142
+ removed = excluded.removed, approved = excluded.approved, reason = excluded.reason, authorBanExpiresAt = excluded.authorBanExpiresAt, updatedAt = excluded.updatedAt, protocolVersion = excluded.protocolVersion,
1122
1143
  signature = excluded.signature, author = excluded.author, replies = excluded.replies, lastChildCid = excluded.lastChildCid,
1123
1144
  lastReplyTimestamp = excluded.lastReplyTimestamp, postUpdatesBucket = excluded.postUpdatesBucket,
1124
1145
  publishedToPostUpdatesMFS = excluded.publishedToPostUpdatesMFS,
@@ -1137,7 +1158,7 @@ export class DbHandler {
1137
1158
  upsertMany(processedUpdates);
1138
1159
  }
1139
1160
  insertCommentModerations(moderations) {
1140
- this._publicationWriteGeneration++;
1161
+ this._notePublicationWrite();
1141
1162
  if (moderations.length === 0)
1142
1163
  return;
1143
1164
  const processedModerations = this._processRecordsForDbBeforeInsert(moderations);
@@ -1160,7 +1181,7 @@ export class DbHandler {
1160
1181
  insertMany(processedModerations);
1161
1182
  }
1162
1183
  insertCommentEdits(edits) {
1163
- this._publicationWriteGeneration++;
1184
+ this._notePublicationWrite();
1164
1185
  if (edits.length === 0)
1165
1186
  return;
1166
1187
  const processedEdits = this._processRecordsForDbBeforeInsert(edits);
@@ -2094,7 +2115,7 @@ export class DbHandler {
2094
2115
  return pick(parsed, ["signature", ...signedKeys, ...commentEditFields]);
2095
2116
  }
2096
2117
  removeCommentFromPendingApproval(comment) {
2097
- this._publicationWriteGeneration++;
2118
+ this._notePublicationWrite();
2098
2119
  const log = Logger("pkc-js:local-community:db-handler:removeCommentFromPendingApproval");
2099
2120
  const stmt = this._db.prepare(`UPDATE ${TABLES.COMMENTS} SET pendingApproval = 0 WHERE cid = ?`);
2100
2121
  const res = stmt.run(comment.cid);
@@ -2335,6 +2356,8 @@ export class DbHandler {
2335
2356
  ...moderation?.flags,
2336
2357
  // moderatorReason wins when present, else fall back to the challenge-supplied reason (if any).
2337
2358
  reason: moderation?.reason ?? comment.challengeCommentUpdate?.reason,
2359
+ // 0 is the mod's revoke: it is the newest ban value on this comment, and it means no mark
2360
+ authorBanExpiresAt: moderation?.authorBanExpiresAt || undefined,
2338
2361
  author: { community: { ...(challengeAuthorCommunity ?? {}), ...authorCommunity } },
2339
2362
  lastChildCid: lastChildCids.get(comment.cid),
2340
2363
  lastReplyTimestamp: lastReplyTimestamps.get(comment.cid),
@@ -2463,6 +2486,9 @@ export class DbHandler {
2463
2486
  }
2464
2487
  // What the moderations of each comment say, newest first, one read for the batch: the latest non-null value per
2465
2488
  // field (reason, flairs, approved and the six flags), the same precedence as the per-field statements this replaces.
2489
+ // authorBanExpiresAt is the newest author.banExpiresAt published on the comment itself, 0 included: a 0 removes the
2490
+ // mark. author.community.banExpiresAt is the newest across all of the author's comments and skips 0 rows
2491
+ // (isAuthorBanRow), so removing a mark never touches the ban.
2466
2492
  _queryModerationSummariesByCids(cids) {
2467
2493
  const FLAG_NAMES = ["spoiler", "pinned", "locked", "archived", "removed", "nsfw"];
2468
2494
  const result = new Map();
@@ -2477,6 +2503,9 @@ export class DbHandler {
2477
2503
  }
2478
2504
  if (summary.reason === undefined && typeof moderation.reason === "string")
2479
2505
  summary.reason = moderation.reason;
2506
+ const banExpiresAt = moderation.author?.banExpiresAt;
2507
+ if (summary.authorBanExpiresAt === undefined && typeof banExpiresAt === "number")
2508
+ summary.authorBanExpiresAt = banExpiresAt;
2480
2509
  if (summary.flairs === undefined && moderation.flairs !== null && moderation.flairs !== undefined)
2481
2510
  summary.flairs = moderation.flairs;
2482
2511
  if (summary.approved === undefined && moderation.approved !== null && moderation.approved !== undefined)
@@ -2622,7 +2651,7 @@ export class DbHandler {
2622
2651
  .filter((row) => (row.targetAuthorSignerAddress !== null && modEditSet.has(row.targetAuthorSignerAddress)) ||
2623
2652
  (need.domain !== undefined && row.targetAuthorDomain === need.domain))
2624
2653
  .map((row) => row.author);
2625
- const banAuthor = modAuthorEdits.find((modEdit) => typeof modEdit?.banExpiresAt === "number");
2654
+ const banAuthor = modAuthorEdits.find(isAuthorBanRow);
2626
2655
  const authorFlairsByMod = modAuthorEdits.find((modEdit) => modEdit?.flairs);
2627
2656
  const modEdits = {};
2628
2657
  if (banAuthor?.banExpiresAt)
@@ -2808,7 +2837,7 @@ export class DbHandler {
2808
2837
  WHERE (${conditions.join(" OR ")}) AND json_extract(commentModeration, '$.author') IS NOT NULL ORDER BY rowid DESC
2809
2838
  `).all(...params);
2810
2839
  const modAuthorEdits = modAuthorEditsRaw.map((r) => JSON.parse(r.commentAuthorJson));
2811
- const banAuthor = modAuthorEdits.find((modEdit) => typeof modEdit?.banExpiresAt === "number");
2840
+ const banAuthor = modAuthorEdits.find(isAuthorBanRow);
2812
2841
  const authorFlairsByMod = modAuthorEdits.find((modEdit) => modEdit?.flairs);
2813
2842
  const aggregateAuthor = {};
2814
2843
  if (banAuthor?.banExpiresAt)
@@ -2937,7 +2966,7 @@ export class DbHandler {
2937
2966
  return allCids;
2938
2967
  }
2939
2968
  purgeComment(cid, isNestedCall = false) {
2940
- this._publicationWriteGeneration++;
2969
+ this._notePublicationWrite();
2941
2970
  const log = Logger("pkc-js:local-community:db-handler:purgeComment");
2942
2971
  const purgedRecords = [];
2943
2972
  const detachedPageCids = [];
@@ -3161,6 +3190,14 @@ export class DbHandler {
3161
3190
  return;
3162
3191
  this._runForEachCidBatch(commentCids, (placeholders) => `UPDATE ${TABLES.COMMENT_UPDATES} SET publishedToPostUpdatesMFS = 1 WHERE cid IN (${placeholders})`);
3163
3192
  }
3193
+ // The posts whose CommentUpdate file was written to this postUpdates bucket and acknowledged. No index backs it:
3194
+ // it is for the rare audit of a bucket MFS may have lost entries of, never for a hot path.
3195
+ queryPublishedPostCidsOfBucket(bucket) {
3196
+ return this._db
3197
+ .prepare(`SELECT cid FROM ${TABLES.COMMENT_UPDATES} WHERE postUpdatesBucket = ? AND publishedToPostUpdatesMFS = 1`)
3198
+ .pluck()
3199
+ .all(bucket);
3200
+ }
3164
3201
  forceUpdateOnAllComments() {
3165
3202
  this._db.prepare(`UPDATE ${TABLES.COMMENT_UPDATES} SET publishedToPostUpdatesMFS = 0`).run();
3166
3203
  }