@twikoojs/edgeone-makers 2.0.12 → 2.0.13

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.
@@ -43,7 +43,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
43
43
  var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
44
44
  //#endregion
45
45
  //#region ../shared/dist/index.mjs
46
- /*! @twikoojs/shared v2.0.12 */
46
+ /*! @twikoojs/shared v2.0.13 */
47
47
  /**
48
48
  * Twikoo 统一版本号常量(构建期占位符)。
49
49
  *
@@ -56,7 +56,7 @@ var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
56
56
  * 占位符字面量由 `@twikoojs/tsdown-config` 的 `VERSION_PLACEHOLDER` 常量定义,
57
57
  * 客户端与服务端统一读取本常量,避免版本号在多包之间手工同步。
58
58
  */
59
- const VERSION = "2.0.12";
59
+ const VERSION = "2.0.13";
60
60
  /**
61
61
  * 后端事件名常量(Scope E:24 个客户端事件 + 1 个服务端内部事件)。
62
62
  *
@@ -25659,33 +25659,26 @@ function commentMatchesKeyword(comment, keyword, options = {}) {
25659
25659
  }
25660
25660
  /**
25661
25661
  * 可见性语义展开(1.x getCommentQuery 的 $or 服务层等价形态):
25662
- * 管理员(未开 HIDE_SPAM)全可见;否则「非垃圾 ∪ 本人评论」双查合并去重。
25662
+ * 管理员(未开 HIDE_SPAM)全可见;否则「非垃圾 + 本人垃圾」双查合并,两组互斥。
25663
25663
  * @param db 数据库
25664
25664
  * @param condition 基础条件
25665
25665
  * @param uid 当前用户
25666
25666
  * @param isAdminUser 是否管理员
25667
25667
  * @param config 全量配置
25668
- * @param options 查询选项(sort/limit 透传主查)
25669
- * @returns 合并去重后的评论
25668
+ * @param options 查询选项(排序和读取上限同时应用于两个分支)
25669
+ * @returns 合并后的评论
25670
25670
  */
25671
25671
  async function queryVisibleComments(db, condition, uid, isAdminUser, config, options) {
25672
25672
  if (isAdminUser && config.HIDE_SPAM !== "true") return db.getComments(condition, options);
25673
- const [notSpam, mine] = await Promise.all([db.getComments({
25673
+ const [notSpam, mySpam] = await Promise.all([db.getComments({
25674
25674
  ...condition,
25675
25675
  isSpam: { [NOT]: true }
25676
25676
  }, options), db.getComments({
25677
25677
  ...condition,
25678
- uid
25679
- })]);
25680
- const seen = /* @__PURE__ */ new Set();
25681
- const merged = [];
25682
- for (const doc of [...notSpam, ...mine]) {
25683
- const id = String(doc._id);
25684
- if (!seen.has(id)) {
25685
- seen.add(id);
25686
- merged.push(doc);
25687
- }
25688
- }
25678
+ uid,
25679
+ isSpam: true
25680
+ }, options)]);
25681
+ const merged = [...notSpam, ...mySpam];
25689
25682
  if (options?.sort) {
25690
25683
  const entries = Object.entries(options.sort);
25691
25684
  merged.sort((a, b) => {
@@ -25786,7 +25779,7 @@ const commentGet = async (ctx) => {
25786
25779
  };
25787
25780
  };
25788
25781
  /**
25789
- * 可见性计数(1.x count 的 $or 语义:取回命中 id 精确去重后计数)。
25782
+ * 可见性计数:非垃圾 + 本人垃圾,两组互斥,避免读取完整文档去重。
25790
25783
  * @param ctx 请求上下文
25791
25784
  * @param condition 基础条件
25792
25785
  * @returns 可见条数
@@ -25794,16 +25787,15 @@ const commentGet = async (ctx) => {
25794
25787
  async function queryVisibleCount(ctx, condition) {
25795
25788
  const db = ctx.adapters.database;
25796
25789
  if (isAdmin(ctx.config, ctx.accessToken) && ctx.config.HIDE_SPAM !== "true") return db.countComments(condition);
25797
- const [a, b] = await Promise.all([db.getComments({
25790
+ const [notSpam, mySpam] = await Promise.all([db.countComments({
25798
25791
  ...condition,
25799
25792
  isSpam: { [NOT]: true }
25800
- }), db.getComments({
25793
+ }), db.countComments({
25801
25794
  ...condition,
25802
- uid: ctx.accessToken
25795
+ uid: ctx.accessToken,
25796
+ isSpam: true
25803
25797
  })]);
25804
- const seen = /* @__PURE__ */ new Set();
25805
- for (const doc of [...a, ...b]) seen.add(String(doc._id));
25806
- return seen.size;
25798
+ return notSpam + mySpam;
25807
25799
  }
25808
25800
  /**
25809
25801
  * COMMENT_GET_FOR_ADMIN 事件处理器(1.x commentGetForAdmin + getCommentSearchCondition
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twikoojs/edgeone-makers",
3
- "version": "2.0.12",
3
+ "version": "2.0.13",
4
4
  "description": "Twikoo comment system backend for Tencent EdgeOne Makers",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -21,14 +21,14 @@
21
21
  "dependencies": {
22
22
  "@cap.js/server": "^4.0.5",
23
23
  "@edgeone/pages-blob": "latest",
24
- "@twikoojs/common": "2.0.12",
25
- "@twikoojs/shared": "2.0.12",
24
+ "@twikoojs/common": "2.0.13",
25
+ "@twikoojs/shared": "2.0.13",
26
26
  "bowser": "^2.14.1",
27
27
  "form-data": "^4.0.6",
28
28
  "html-to-text": "^10.0.1",
29
29
  "marked": "^18.0.13",
30
30
  "pako": "^3.0.2",
31
- "pushoo": "^2.0.12",
31
+ "pushoo": "^2.0.13",
32
32
  "xml2js": "^0.6.2"
33
33
  },
34
34
  "devDependencies": {