openzca 0.1.26 → 0.1.27
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/README.md +1 -1
- package/dist/cli.js +17 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -273,7 +273,7 @@ Listener resilience override:
|
|
|
273
273
|
- Default: enabled.
|
|
274
274
|
- Set to `0` to keep only quote metadata/URLs without downloading.
|
|
275
275
|
- `OPENZCA_RECENT_USER_MAX_PAGES`: max websocket history pages to scan for `msg recent` in user/DM mode.
|
|
276
|
-
- Default: `
|
|
276
|
+
- Default: `20`.
|
|
277
277
|
- Increase if a DM thread is old and not found in the first page.
|
|
278
278
|
- `OPENZCA_LISTEN_ENFORCE_SINGLE_OWNER`: enforce one `listen` owner process per profile.
|
|
279
279
|
- Default: enabled.
|
package/dist/cli.js
CHANGED
|
@@ -1582,6 +1582,12 @@ function sortRecentMessagesNewestFirst(messages) {
|
|
|
1582
1582
|
return rightCliMsgId.localeCompare(leftCliMsgId);
|
|
1583
1583
|
});
|
|
1584
1584
|
}
|
|
1585
|
+
function getRecentMessageCursor(message) {
|
|
1586
|
+
if (!message) return "";
|
|
1587
|
+
const actionId = String(message.data?.actionId ?? "").trim();
|
|
1588
|
+
if (actionId) return actionId;
|
|
1589
|
+
return String(message.data?.msgId ?? "").trim();
|
|
1590
|
+
}
|
|
1585
1591
|
async function fetchRecentGroupMessagesViaApi(api, threadId, count) {
|
|
1586
1592
|
const historyApi = api.getGroupChatHistory;
|
|
1587
1593
|
if (typeof historyApi !== "function") {
|
|
@@ -1598,21 +1604,22 @@ async function fetchRecentUserMessagesViaListener(api, threadId, count) {
|
|
|
1598
1604
|
let settled = false;
|
|
1599
1605
|
const collected = [];
|
|
1600
1606
|
const seenMessageKeys = /* @__PURE__ */ new Set();
|
|
1601
|
-
const
|
|
1602
|
-
const maxPages = parsePositiveIntFromEnv("OPENZCA_RECENT_USER_MAX_PAGES",
|
|
1607
|
+
const requestedCursors = /* @__PURE__ */ new Set();
|
|
1608
|
+
const maxPages = parsePositiveIntFromEnv("OPENZCA_RECENT_USER_MAX_PAGES", 20);
|
|
1603
1609
|
let pagesRequested = 0;
|
|
1604
1610
|
const toKey = (message) => {
|
|
1605
1611
|
const msgId = String(message.data?.msgId ?? "");
|
|
1606
1612
|
const cliMsgId = String(message.data?.cliMsgId ?? "");
|
|
1607
1613
|
return `${msgId}:${cliMsgId}`;
|
|
1608
1614
|
};
|
|
1609
|
-
const requestPage = (
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1615
|
+
const requestPage = (lastId) => {
|
|
1616
|
+
const cursor = String(lastId ?? "").trim();
|
|
1617
|
+
if (cursor) {
|
|
1618
|
+
if (requestedCursors.has(cursor)) return false;
|
|
1619
|
+
requestedCursors.add(cursor);
|
|
1613
1620
|
}
|
|
1614
1621
|
pagesRequested += 1;
|
|
1615
|
-
api.listener.requestOldMessages(ThreadType.User,
|
|
1622
|
+
api.listener.requestOldMessages(ThreadType.User, cursor || null);
|
|
1616
1623
|
return true;
|
|
1617
1624
|
};
|
|
1618
1625
|
const cleanup = () => {
|
|
@@ -1676,13 +1683,13 @@ async function fetchRecentUserMessagesViaListener(api, threadId, count) {
|
|
|
1676
1683
|
oldest = message;
|
|
1677
1684
|
}
|
|
1678
1685
|
}
|
|
1679
|
-
const
|
|
1680
|
-
if (!
|
|
1686
|
+
const nextCursor = getRecentMessageCursor(oldest);
|
|
1687
|
+
if (!nextCursor) {
|
|
1681
1688
|
finish();
|
|
1682
1689
|
return;
|
|
1683
1690
|
}
|
|
1684
1691
|
try {
|
|
1685
|
-
const requested = requestPage(
|
|
1692
|
+
const requested = requestPage(nextCursor);
|
|
1686
1693
|
if (!requested) {
|
|
1687
1694
|
finish();
|
|
1688
1695
|
}
|