refactor: consolidate runtime helpers
This commit is contained in:
10
src/message-cursor.ts
Normal file
10
src/message-cursor.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { getLatestMessageSeqAtOrBefore } from './db.js';
|
||||
|
||||
export function normalizeStoredSeqCursor(
|
||||
cursor: string | undefined,
|
||||
chatJid?: string,
|
||||
): string {
|
||||
if (!cursor) return '0';
|
||||
if (/^\d+$/.test(cursor.trim())) return cursor.trim();
|
||||
return String(getLatestMessageSeqAtOrBefore(cursor, chatJid));
|
||||
}
|
||||
Reference in New Issue
Block a user