@pkcprotocol/pkc-js 0.0.157 → 0.0.159

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 (152) hide show
  1. package/README.md +58 -3
  2. package/dist/browser/clients/base-client-manager.js +24 -11
  3. package/dist/browser/clients/base-client-manager.js.map +1 -1
  4. package/dist/browser/clients/rpc-client/pkc-rpc-client.js +17 -9
  5. package/dist/browser/clients/rpc-client/pkc-rpc-client.js.map +1 -1
  6. package/dist/browser/clients/rpc-client/schema.d.ts +2 -0
  7. package/dist/browser/community/schema.d.ts +26 -0
  8. package/dist/browser/detached-guard.d.ts +5 -0
  9. package/dist/browser/detached-guard.js +50 -0
  10. package/dist/browser/detached-guard.js.map +1 -0
  11. package/dist/browser/errors.d.ts +2 -0
  12. package/dist/browser/errors.js +2 -0
  13. package/dist/browser/errors.js.map +1 -1
  14. package/dist/browser/generated-version.d.ts +1 -1
  15. package/dist/browser/generated-version.js +1 -1
  16. package/dist/browser/helia/helia-for-pkc.js +6 -5
  17. package/dist/browser/helia/helia-for-pkc.js.map +1 -1
  18. package/dist/browser/index-with-compile-cache.d.ts +4 -0
  19. package/dist/browser/index.d.ts +8 -0
  20. package/dist/browser/pages/schema.d.ts +6 -0
  21. package/dist/browser/pkc-error.d.ts +1 -1
  22. package/dist/browser/publications/comment/comment.d.ts +2 -0
  23. package/dist/browser/publications/comment/comment.js +2 -0
  24. package/dist/browser/publications/comment/comment.js.map +1 -1
  25. package/dist/browser/publications/comment/schema.d.ts +6 -2
  26. package/dist/browser/publications/comment/schema.js +13 -1
  27. package/dist/browser/publications/comment/schema.js.map +1 -1
  28. package/dist/browser/publications/comment-moderation/schema.js +2 -2
  29. package/dist/browser/publications/comment-moderation/schema.js.map +1 -1
  30. package/dist/browser/publications/publication.js +26 -32
  31. package/dist/browser/publications/publication.js.map +1 -1
  32. package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +4 -0
  33. package/dist/browser/rpc/src/schema.d.ts +24 -0
  34. package/dist/browser/runtime/node/community/db-handler.d.ts +1 -0
  35. package/dist/browser/runtime/node/community/db-handler.js +31 -7
  36. package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
  37. package/dist/browser/runtime/node/community/local-community/cleanup.js +6 -0
  38. package/dist/browser/runtime/node/community/local-community/cleanup.js.map +1 -1
  39. package/dist/browser/runtime/node/community/local-community/comment-updates.js +36 -0
  40. package/dist/browser/runtime/node/community/local-community/comment-updates.js.map +1 -1
  41. package/dist/browser/runtime/node/community/local-community/db-fault.d.ts +3 -0
  42. package/dist/browser/runtime/node/community/local-community/db-fault.js +13 -0
  43. package/dist/browser/runtime/node/community/local-community/db-fault.js.map +1 -0
  44. package/dist/browser/runtime/node/community/local-community/ipns-publishing.js +36 -2
  45. package/dist/browser/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
  46. package/dist/browser/runtime/node/community/local-community/lifecycle.js +36 -2
  47. package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
  48. package/dist/browser/runtime/node/community/local-community/post-updates-bucket.d.ts +21 -0
  49. package/dist/browser/runtime/node/community/local-community/post-updates-bucket.js +141 -4
  50. package/dist/browser/runtime/node/community/local-community/post-updates-bucket.js.map +1 -1
  51. package/dist/browser/runtime/node/community/local-community.d.ts +7 -0
  52. package/dist/browser/runtime/node/community/local-community.js +18 -0
  53. package/dist/browser/runtime/node/community/local-community.js.map +1 -1
  54. package/dist/browser/runtime/node/test/helpers/hanging-runner.js +7 -3
  55. package/dist/browser/runtime/node/test/helpers/hanging-runner.js.map +1 -1
  56. package/dist/browser/runtime/node/test/helpers/run-hanging-node.js +6 -1
  57. package/dist/browser/runtime/node/test/helpers/run-hanging-node.js.map +1 -1
  58. package/dist/browser/schema/schema-util.d.ts +10 -0
  59. package/dist/browser/schema/schema.d.ts +9 -0
  60. package/dist/browser/schema/schema.js +9 -1
  61. package/dist/browser/schema/schema.js.map +1 -1
  62. package/dist/browser/schema.d.ts +32 -0
  63. package/dist/browser/signer/pseudonymity-author-tag.d.ts +8 -0
  64. package/dist/browser/signer/pseudonymity-author-tag.js +39 -0
  65. package/dist/browser/signer/pseudonymity-author-tag.js.map +1 -0
  66. package/dist/browser/signer/signatures.js +16 -0
  67. package/dist/browser/signer/signatures.js.map +1 -1
  68. package/dist/browser/test/test-util.d.ts +10 -0
  69. package/dist/browser/version.js +1 -1
  70. package/dist/bundled/bundle-manifest.json +58 -53
  71. package/dist/bundled/challenges.js +1 -1
  72. package/dist/bundled/chunks/{helia-for-pkc-BT2UmDem.js → helia-for-pkc-CP5A7i4M.js} +5 -4
  73. package/dist/bundled/chunks/{local-community-oqjqTa9T.js → local-community-0xsjgulY.js} +373 -26
  74. package/dist/bundled/chunks/{local-community-BexngGU7.js → local-community-CUDfHfH_.js} +1 -1
  75. package/dist/bundled/chunks/{node-CvXtQ-4A.js → node-Bv7hIiW_.js} +40 -38
  76. package/dist/bundled/chunks/{page-sort-scoring-VN_GGInQ.js → page-sort-scoring-I02fuGkI.js} +1 -1
  77. package/dist/bundled/chunks/{rpc-local-community-BjIHRbYy.js → rpc-local-community-Bo4Z7ilA.js} +57 -13
  78. package/dist/bundled/chunks/{util-DDsWXOtP.js → util-BZuCmqxu.js} +12 -9
  79. package/dist/bundled/chunks/{util-Bu3ItQsN.js → util-xhgmI11L.js} +1 -1
  80. package/dist/bundled/chunks/{validate-package-factories-CmJt781W.js → validate-package-factories-BsSEIr__.js} +2 -2
  81. package/dist/bundled/index.js +1 -1
  82. package/dist/bundled/page-sorts.js +1 -1
  83. package/dist/bundled/rpc/src/index.js +4 -4
  84. package/dist/node/clients/base-client-manager.js +24 -11
  85. package/dist/node/clients/base-client-manager.js.map +1 -1
  86. package/dist/node/clients/rpc-client/pkc-rpc-client.js +17 -9
  87. package/dist/node/clients/rpc-client/pkc-rpc-client.js.map +1 -1
  88. package/dist/node/clients/rpc-client/schema.d.ts +2 -0
  89. package/dist/node/community/schema.d.ts +26 -0
  90. package/dist/node/detached-guard.d.ts +5 -0
  91. package/dist/node/detached-guard.js +50 -0
  92. package/dist/node/detached-guard.js.map +1 -0
  93. package/dist/node/errors.d.ts +2 -0
  94. package/dist/node/errors.js +2 -0
  95. package/dist/node/errors.js.map +1 -1
  96. package/dist/node/generated-version.d.ts +1 -1
  97. package/dist/node/generated-version.js +1 -1
  98. package/dist/node/helia/helia-for-pkc.js +6 -5
  99. package/dist/node/helia/helia-for-pkc.js.map +1 -1
  100. package/dist/node/index-with-compile-cache.d.ts +4 -0
  101. package/dist/node/index.d.ts +8 -0
  102. package/dist/node/pages/schema.d.ts +6 -0
  103. package/dist/node/pkc-error.d.ts +1 -1
  104. package/dist/node/publications/comment/comment.d.ts +2 -0
  105. package/dist/node/publications/comment/comment.js +2 -0
  106. package/dist/node/publications/comment/comment.js.map +1 -1
  107. package/dist/node/publications/comment/schema.d.ts +6 -2
  108. package/dist/node/publications/comment/schema.js +13 -1
  109. package/dist/node/publications/comment/schema.js.map +1 -1
  110. package/dist/node/publications/comment-moderation/schema.js +2 -2
  111. package/dist/node/publications/comment-moderation/schema.js.map +1 -1
  112. package/dist/node/publications/publication.js +26 -32
  113. package/dist/node/publications/publication.js.map +1 -1
  114. package/dist/node/rpc/src/lib/pkc-js/index.d.ts +4 -0
  115. package/dist/node/rpc/src/schema.d.ts +24 -0
  116. package/dist/node/runtime/node/community/db-handler.d.ts +1 -0
  117. package/dist/node/runtime/node/community/db-handler.js +31 -7
  118. package/dist/node/runtime/node/community/db-handler.js.map +1 -1
  119. package/dist/node/runtime/node/community/local-community/cleanup.js +6 -0
  120. package/dist/node/runtime/node/community/local-community/cleanup.js.map +1 -1
  121. package/dist/node/runtime/node/community/local-community/comment-updates.js +36 -0
  122. package/dist/node/runtime/node/community/local-community/comment-updates.js.map +1 -1
  123. package/dist/node/runtime/node/community/local-community/db-fault.d.ts +3 -0
  124. package/dist/node/runtime/node/community/local-community/db-fault.js +13 -0
  125. package/dist/node/runtime/node/community/local-community/db-fault.js.map +1 -0
  126. package/dist/node/runtime/node/community/local-community/ipns-publishing.js +36 -2
  127. package/dist/node/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
  128. package/dist/node/runtime/node/community/local-community/lifecycle.js +36 -2
  129. package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
  130. package/dist/node/runtime/node/community/local-community/post-updates-bucket.d.ts +21 -0
  131. package/dist/node/runtime/node/community/local-community/post-updates-bucket.js +141 -4
  132. package/dist/node/runtime/node/community/local-community/post-updates-bucket.js.map +1 -1
  133. package/dist/node/runtime/node/community/local-community.d.ts +7 -0
  134. package/dist/node/runtime/node/community/local-community.js +18 -0
  135. package/dist/node/runtime/node/community/local-community.js.map +1 -1
  136. package/dist/node/runtime/node/test/helpers/hanging-runner.js +7 -3
  137. package/dist/node/runtime/node/test/helpers/hanging-runner.js.map +1 -1
  138. package/dist/node/runtime/node/test/helpers/run-hanging-node.js +6 -1
  139. package/dist/node/runtime/node/test/helpers/run-hanging-node.js.map +1 -1
  140. package/dist/node/schema/schema-util.d.ts +10 -0
  141. package/dist/node/schema/schema.d.ts +9 -0
  142. package/dist/node/schema/schema.js +9 -1
  143. package/dist/node/schema/schema.js.map +1 -1
  144. package/dist/node/schema.d.ts +32 -0
  145. package/dist/node/signer/pseudonymity-author-tag.d.ts +8 -0
  146. package/dist/node/signer/pseudonymity-author-tag.js +39 -0
  147. package/dist/node/signer/pseudonymity-author-tag.js.map +1 -0
  148. package/dist/node/signer/signatures.js +16 -0
  149. package/dist/node/signer/signatures.js.map +1 -1
  150. package/dist/node/test/test-util.d.ts +10 -0
  151. package/dist/node/version.js +1 -1
  152. package/package.json +3 -2
@@ -478,6 +478,7 @@ export declare const CreatePKCWsServerOptionsSchema: z.ZodObject<{
478
478
  archived?: boolean | undefined;
479
479
  removed?: boolean | undefined;
480
480
  reason?: string | undefined;
481
+ authorBanExpiresAt?: number | undefined;
481
482
  approved?: boolean | undefined;
482
483
  author?: {
483
484
  [x: string]: unknown;
@@ -499,6 +500,7 @@ export declare const CreatePKCWsServerOptionsSchema: z.ZodObject<{
499
500
  } | undefined;
500
501
  lastChildCid?: string | undefined;
501
502
  lastReplyTimestamp?: number | undefined;
503
+ pseudonymityAuthorTag?: string | undefined;
502
504
  replies?: {
503
505
  pages: Record<string, {
504
506
  comments: {
@@ -675,6 +677,7 @@ export declare const CreatePKCWsServerOptionsSchema: z.ZodObject<{
675
677
  archived?: boolean | undefined;
676
678
  removed?: boolean | undefined;
677
679
  reason?: string | undefined;
680
+ authorBanExpiresAt?: number | undefined;
678
681
  approved?: boolean | undefined;
679
682
  author?: {
680
683
  [x: string]: unknown;
@@ -696,6 +699,7 @@ export declare const CreatePKCWsServerOptionsSchema: z.ZodObject<{
696
699
  } | undefined;
697
700
  lastChildCid?: string | undefined;
698
701
  lastReplyTimestamp?: number | undefined;
702
+ pseudonymityAuthorTag?: string | undefined;
699
703
  replies?: {
700
704
  pages: Record<string, {
701
705
  comments: {
@@ -1284,6 +1288,7 @@ export declare const CreatePKCWsServerOptionsSchema: z.ZodObject<{
1284
1288
  archived?: boolean | undefined;
1285
1289
  removed?: boolean | undefined;
1286
1290
  reason?: string | undefined;
1291
+ authorBanExpiresAt?: number | undefined;
1287
1292
  approved?: boolean | undefined;
1288
1293
  author?: {
1289
1294
  [x: string]: unknown;
@@ -1305,6 +1310,7 @@ export declare const CreatePKCWsServerOptionsSchema: z.ZodObject<{
1305
1310
  } | undefined;
1306
1311
  lastChildCid?: string | undefined;
1307
1312
  lastReplyTimestamp?: number | undefined;
1313
+ pseudonymityAuthorTag?: string | undefined;
1308
1314
  replies?: {
1309
1315
  pages: Record<string, {
1310
1316
  comments: {
@@ -1481,6 +1487,7 @@ export declare const CreatePKCWsServerOptionsSchema: z.ZodObject<{
1481
1487
  archived?: boolean | undefined;
1482
1488
  removed?: boolean | undefined;
1483
1489
  reason?: string | undefined;
1490
+ authorBanExpiresAt?: number | undefined;
1484
1491
  approved?: boolean | undefined;
1485
1492
  author?: {
1486
1493
  [x: string]: unknown;
@@ -1502,6 +1509,7 @@ export declare const CreatePKCWsServerOptionsSchema: z.ZodObject<{
1502
1509
  } | undefined;
1503
1510
  lastChildCid?: string | undefined;
1504
1511
  lastReplyTimestamp?: number | undefined;
1512
+ pseudonymityAuthorTag?: string | undefined;
1505
1513
  replies?: {
1506
1514
  pages: Record<string, {
1507
1515
  comments: {
@@ -2297,6 +2305,7 @@ export declare const SetNewSettingsPKCWsServerSchema: z.ZodObject<{
2297
2305
  archived?: boolean | undefined;
2298
2306
  removed?: boolean | undefined;
2299
2307
  reason?: string | undefined;
2308
+ authorBanExpiresAt?: number | undefined;
2300
2309
  approved?: boolean | undefined;
2301
2310
  author?: {
2302
2311
  [x: string]: unknown;
@@ -2318,6 +2327,7 @@ export declare const SetNewSettingsPKCWsServerSchema: z.ZodObject<{
2318
2327
  } | undefined;
2319
2328
  lastChildCid?: string | undefined;
2320
2329
  lastReplyTimestamp?: number | undefined;
2330
+ pseudonymityAuthorTag?: string | undefined;
2321
2331
  replies?: {
2322
2332
  pages: Record<string, {
2323
2333
  comments: {
@@ -2494,6 +2504,7 @@ export declare const SetNewSettingsPKCWsServerSchema: z.ZodObject<{
2494
2504
  archived?: boolean | undefined;
2495
2505
  removed?: boolean | undefined;
2496
2506
  reason?: string | undefined;
2507
+ authorBanExpiresAt?: number | undefined;
2497
2508
  approved?: boolean | undefined;
2498
2509
  author?: {
2499
2510
  [x: string]: unknown;
@@ -2515,6 +2526,7 @@ export declare const SetNewSettingsPKCWsServerSchema: z.ZodObject<{
2515
2526
  } | undefined;
2516
2527
  lastChildCid?: string | undefined;
2517
2528
  lastReplyTimestamp?: number | undefined;
2529
+ pseudonymityAuthorTag?: string | undefined;
2518
2530
  replies?: {
2519
2531
  pages: Record<string, {
2520
2532
  comments: {
@@ -2889,6 +2901,7 @@ export declare const SetNewSettingsPKCWsServerSchema: z.ZodObject<{
2889
2901
  archived?: boolean | undefined;
2890
2902
  removed?: boolean | undefined;
2891
2903
  reason?: string | undefined;
2904
+ authorBanExpiresAt?: number | undefined;
2892
2905
  approved?: boolean | undefined;
2893
2906
  author?: {
2894
2907
  [x: string]: unknown;
@@ -2910,6 +2923,7 @@ export declare const SetNewSettingsPKCWsServerSchema: z.ZodObject<{
2910
2923
  } | undefined;
2911
2924
  lastChildCid?: string | undefined;
2912
2925
  lastReplyTimestamp?: number | undefined;
2926
+ pseudonymityAuthorTag?: string | undefined;
2913
2927
  replies?: {
2914
2928
  pages: Record<string, {
2915
2929
  comments: {
@@ -3086,6 +3100,7 @@ export declare const SetNewSettingsPKCWsServerSchema: z.ZodObject<{
3086
3100
  archived?: boolean | undefined;
3087
3101
  removed?: boolean | undefined;
3088
3102
  reason?: string | undefined;
3103
+ authorBanExpiresAt?: number | undefined;
3089
3104
  approved?: boolean | undefined;
3090
3105
  author?: {
3091
3106
  [x: string]: unknown;
@@ -3107,6 +3122,7 @@ export declare const SetNewSettingsPKCWsServerSchema: z.ZodObject<{
3107
3122
  } | undefined;
3108
3123
  lastChildCid?: string | undefined;
3109
3124
  lastReplyTimestamp?: number | undefined;
3125
+ pseudonymityAuthorTag?: string | undefined;
3110
3126
  replies?: {
3111
3127
  pages: Record<string, {
3112
3128
  comments: {
@@ -3888,6 +3904,7 @@ export declare const PKCWsServerSettingsSerializedSchema: z.ZodObject<{
3888
3904
  archived?: boolean | undefined;
3889
3905
  removed?: boolean | undefined;
3890
3906
  reason?: string | undefined;
3907
+ authorBanExpiresAt?: number | undefined;
3891
3908
  approved?: boolean | undefined;
3892
3909
  author?: {
3893
3910
  [x: string]: unknown;
@@ -3909,6 +3926,7 @@ export declare const PKCWsServerSettingsSerializedSchema: z.ZodObject<{
3909
3926
  } | undefined;
3910
3927
  lastChildCid?: string | undefined;
3911
3928
  lastReplyTimestamp?: number | undefined;
3929
+ pseudonymityAuthorTag?: string | undefined;
3912
3930
  replies?: {
3913
3931
  pages: Record<string, {
3914
3932
  comments: {
@@ -4085,6 +4103,7 @@ export declare const PKCWsServerSettingsSerializedSchema: z.ZodObject<{
4085
4103
  archived?: boolean | undefined;
4086
4104
  removed?: boolean | undefined;
4087
4105
  reason?: string | undefined;
4106
+ authorBanExpiresAt?: number | undefined;
4088
4107
  approved?: boolean | undefined;
4089
4108
  author?: {
4090
4109
  [x: string]: unknown;
@@ -4106,6 +4125,7 @@ export declare const PKCWsServerSettingsSerializedSchema: z.ZodObject<{
4106
4125
  } | undefined;
4107
4126
  lastChildCid?: string | undefined;
4108
4127
  lastReplyTimestamp?: number | undefined;
4128
+ pseudonymityAuthorTag?: string | undefined;
4109
4129
  replies?: {
4110
4130
  pages: Record<string, {
4111
4131
  comments: {
@@ -4480,6 +4500,7 @@ export declare const PKCWsServerSettingsSerializedSchema: z.ZodObject<{
4480
4500
  archived?: boolean | undefined;
4481
4501
  removed?: boolean | undefined;
4482
4502
  reason?: string | undefined;
4503
+ authorBanExpiresAt?: number | undefined;
4483
4504
  approved?: boolean | undefined;
4484
4505
  author?: {
4485
4506
  [x: string]: unknown;
@@ -4501,6 +4522,7 @@ export declare const PKCWsServerSettingsSerializedSchema: z.ZodObject<{
4501
4522
  } | undefined;
4502
4523
  lastChildCid?: string | undefined;
4503
4524
  lastReplyTimestamp?: number | undefined;
4525
+ pseudonymityAuthorTag?: string | undefined;
4504
4526
  replies?: {
4505
4527
  pages: Record<string, {
4506
4528
  comments: {
@@ -4677,6 +4699,7 @@ export declare const PKCWsServerSettingsSerializedSchema: z.ZodObject<{
4677
4699
  archived?: boolean | undefined;
4678
4700
  removed?: boolean | undefined;
4679
4701
  reason?: string | undefined;
4702
+ authorBanExpiresAt?: number | undefined;
4680
4703
  approved?: boolean | undefined;
4681
4704
  author?: {
4682
4705
  [x: string]: unknown;
@@ -4698,6 +4721,7 @@ export declare const PKCWsServerSettingsSerializedSchema: z.ZodObject<{
4698
4721
  } | undefined;
4699
4722
  lastChildCid?: string | undefined;
4700
4723
  lastReplyTimestamp?: number | undefined;
4724
+ pseudonymityAuthorTag?: string | undefined;
4701
4725
  replies?: {
4702
4726
  pages: Record<string, {
4703
4727
  comments: {
@@ -305,6 +305,7 @@ export declare class DbHandler {
305
305
  runInWriteTransaction<T>(write: () => T): T;
306
306
  communityDbExists(): boolean;
307
307
  markCommentsAsPublishedToPostUpdates(commentCids: string[]): void;
308
+ queryPublishedPostCidsOfBucket(bucket: number): string[];
308
309
  forceUpdateOnAllComments(): void;
309
310
  forceUpdateOnAllCommentsWithCid(commentCids: string[]): void;
310
311
  private _runForEachCidBatch;
@@ -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);
@@ -365,13 +371,15 @@ export class DbHandler {
365
371
  removed INTEGER NULLABLE, -- BOOLEAN (0/1)
366
372
  approved INTEGER NULLABLE, -- BOOLEAN (0/1)
367
373
  reason TEXT NULLABLE,
374
+ authorBanExpiresAt INTEGER NULLABLE, -- the ban a mod published on this comment (issue #363)
368
375
  updatedAt INTEGER NOT NULL CHECK(updatedAt > 0),
369
376
  protocolVersion TEXT NOT NULL,
370
377
  signature TEXT NOT NULL, -- JSON
371
378
  author TEXT NULLABLE, -- JSON
372
379
  replies TEXT NULLABLE, -- JSON: CID refs per sort (DbRepliesSchema)
373
380
  lastChildCid TEXT NULLABLE,
374
- lastReplyTimestamp INTEGER NULLABLE,
381
+ lastReplyTimestamp INTEGER NULLABLE,
382
+ pseudonymityAuthorTag TEXT NULLABLE, -- own-post recognition tag on aliased comments (issue #381); a signed CommentUpdate field
375
383
  postUpdatesBucket INTEGER NULLABLE,
376
384
  publishedToPostUpdatesMFS INTEGER NOT NULL, -- BOOLEAN (0/1)
377
385
  insertedAt INTEGER NOT NULL,
@@ -1125,16 +1133,16 @@ export class DbHandler {
1125
1133
  const columnNames = this._getColumnNames(TABLES.COMMENT_UPDATES);
1126
1134
  const stmt = this._prepareCached(`
1127
1135
  INSERT INTO ${TABLES.COMMENT_UPDATES}
1128
- (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)
1129
- 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)
1136
+ (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, pseudonymityAuthorTag, postUpdatesBucket, publishedToPostUpdatesMFS, insertedAt, extraProps)
1137
+ 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, @pseudonymityAuthorTag, @postUpdatesBucket, @publishedToPostUpdatesMFS, @insertedAt, @extraProps)
1130
1138
  ON CONFLICT(cid) DO UPDATE SET
1131
1139
  edit = excluded.edit, upvoteCount = excluded.upvoteCount, downvoteCount = excluded.downvoteCount, replyCount = excluded.replyCount, childCount = excluded.childCount,
1132
1140
  number = COALESCE(excluded.number, ${TABLES.COMMENT_UPDATES}.number),
1133
1141
  postNumber = COALESCE(excluded.postNumber, ${TABLES.COMMENT_UPDATES}.postNumber),
1134
1142
  flairs = excluded.flairs, spoiler = excluded.spoiler, nsfw = excluded.nsfw, pinned = excluded.pinned, locked = excluded.locked, archived = excluded.archived,
1135
- removed = excluded.removed, approved = excluded.approved, reason = excluded.reason, updatedAt = excluded.updatedAt, protocolVersion = excluded.protocolVersion,
1143
+ removed = excluded.removed, approved = excluded.approved, reason = excluded.reason, authorBanExpiresAt = excluded.authorBanExpiresAt, updatedAt = excluded.updatedAt, protocolVersion = excluded.protocolVersion,
1136
1144
  signature = excluded.signature, author = excluded.author, replies = excluded.replies, lastChildCid = excluded.lastChildCid,
1137
- lastReplyTimestamp = excluded.lastReplyTimestamp, postUpdatesBucket = excluded.postUpdatesBucket,
1145
+ lastReplyTimestamp = excluded.lastReplyTimestamp, pseudonymityAuthorTag = excluded.pseudonymityAuthorTag, postUpdatesBucket = excluded.postUpdatesBucket,
1138
1146
  publishedToPostUpdatesMFS = excluded.publishedToPostUpdatesMFS,
1139
1147
  insertedAt = excluded.insertedAt,
1140
1148
  extraProps = excluded.extraProps
@@ -2349,6 +2357,8 @@ export class DbHandler {
2349
2357
  ...moderation?.flags,
2350
2358
  // moderatorReason wins when present, else fall back to the challenge-supplied reason (if any).
2351
2359
  reason: moderation?.reason ?? comment.challengeCommentUpdate?.reason,
2360
+ // 0 is the mod's revoke: it is the newest ban value on this comment, and it means no mark
2361
+ authorBanExpiresAt: moderation?.authorBanExpiresAt || undefined,
2352
2362
  author: { community: { ...(challengeAuthorCommunity ?? {}), ...authorCommunity } },
2353
2363
  lastChildCid: lastChildCids.get(comment.cid),
2354
2364
  lastReplyTimestamp: lastReplyTimestamps.get(comment.cid),
@@ -2477,6 +2487,9 @@ export class DbHandler {
2477
2487
  }
2478
2488
  // What the moderations of each comment say, newest first, one read for the batch: the latest non-null value per
2479
2489
  // field (reason, flairs, approved and the six flags), the same precedence as the per-field statements this replaces.
2490
+ // authorBanExpiresAt is the newest author.banExpiresAt published on the comment itself, 0 included: a 0 removes the
2491
+ // mark. author.community.banExpiresAt is the newest across all of the author's comments and skips 0 rows
2492
+ // (isAuthorBanRow), so removing a mark never touches the ban.
2480
2493
  _queryModerationSummariesByCids(cids) {
2481
2494
  const FLAG_NAMES = ["spoiler", "pinned", "locked", "archived", "removed", "nsfw"];
2482
2495
  const result = new Map();
@@ -2491,6 +2504,9 @@ export class DbHandler {
2491
2504
  }
2492
2505
  if (summary.reason === undefined && typeof moderation.reason === "string")
2493
2506
  summary.reason = moderation.reason;
2507
+ const banExpiresAt = moderation.author?.banExpiresAt;
2508
+ if (summary.authorBanExpiresAt === undefined && typeof banExpiresAt === "number")
2509
+ summary.authorBanExpiresAt = banExpiresAt;
2494
2510
  if (summary.flairs === undefined && moderation.flairs !== null && moderation.flairs !== undefined)
2495
2511
  summary.flairs = moderation.flairs;
2496
2512
  if (summary.approved === undefined && moderation.approved !== null && moderation.approved !== undefined)
@@ -2636,7 +2652,7 @@ export class DbHandler {
2636
2652
  .filter((row) => (row.targetAuthorSignerAddress !== null && modEditSet.has(row.targetAuthorSignerAddress)) ||
2637
2653
  (need.domain !== undefined && row.targetAuthorDomain === need.domain))
2638
2654
  .map((row) => row.author);
2639
- const banAuthor = modAuthorEdits.find((modEdit) => typeof modEdit?.banExpiresAt === "number");
2655
+ const banAuthor = modAuthorEdits.find(isAuthorBanRow);
2640
2656
  const authorFlairsByMod = modAuthorEdits.find((modEdit) => modEdit?.flairs);
2641
2657
  const modEdits = {};
2642
2658
  if (banAuthor?.banExpiresAt)
@@ -2822,7 +2838,7 @@ export class DbHandler {
2822
2838
  WHERE (${conditions.join(" OR ")}) AND json_extract(commentModeration, '$.author') IS NOT NULL ORDER BY rowid DESC
2823
2839
  `).all(...params);
2824
2840
  const modAuthorEdits = modAuthorEditsRaw.map((r) => JSON.parse(r.commentAuthorJson));
2825
- const banAuthor = modAuthorEdits.find((modEdit) => typeof modEdit?.banExpiresAt === "number");
2841
+ const banAuthor = modAuthorEdits.find(isAuthorBanRow);
2826
2842
  const authorFlairsByMod = modAuthorEdits.find((modEdit) => modEdit?.flairs);
2827
2843
  const aggregateAuthor = {};
2828
2844
  if (banAuthor?.banExpiresAt)
@@ -3175,6 +3191,14 @@ export class DbHandler {
3175
3191
  return;
3176
3192
  this._runForEachCidBatch(commentCids, (placeholders) => `UPDATE ${TABLES.COMMENT_UPDATES} SET publishedToPostUpdatesMFS = 1 WHERE cid IN (${placeholders})`);
3177
3193
  }
3194
+ // The posts whose CommentUpdate file was written to this postUpdates bucket and acknowledged. No index backs it:
3195
+ // it is for the rare audit of a bucket MFS may have lost entries of, never for a hot path.
3196
+ queryPublishedPostCidsOfBucket(bucket) {
3197
+ return this._db
3198
+ .prepare(`SELECT cid FROM ${TABLES.COMMENT_UPDATES} WHERE postUpdatesBucket = ? AND publishedToPostUpdatesMFS = 1`)
3199
+ .pluck()
3200
+ .all(bucket);
3201
+ }
3178
3202
  forceUpdateOnAllComments() {
3179
3203
  this._db.prepare(`UPDATE ${TABLES.COMMENT_UPDATES} SET publishedToPostUpdatesMFS = 0`).run();
3180
3204
  }