anbot

174e82a / anbot.mjs

View file at this commit

diff --cc anbot.mjs
index 33e2021,cceb257..a9a997c
--- a/anbot.mjs
+++ b/anbot.mjs
@@@ -6,11 -6,11 +6,11 @@@ import { basename, dirname, isAbsolute
  import { parseArgs } from 'node:util'
  import {
    checkoutRoot, clonePath, commitStat, gitEnv, gitOptions, listCommits, listTree,
 -  publish, readBlob, readCommit, repositoryName, selectedRepository, verifySelection
 +  publish, readBlob, readCommit, readPushAnnouncements, repositoryName, selectedRepository, verifySelection
  } from './repository.mjs'
  import {
-   createFsStore, initializeStore, listVerifiedRecords, loadIdentity, readRecordAuthor,
-   recordPath, requireThat
+   createFsStore, initializeStore, listVerifiedPosts, listVerifiedRecords, loadIdentity,
+   readRecordAuthor, recordPath, requireThat
  } from './storage.mjs'
  import {
    base64Decode, base64Encode, maxManifest, parseJson, utf8Encode, verifyBlock
@@@ -138,20 -136,9 +138,20 @@@ async function servePoll(root, response
      return
    }
    try {
 -    // Git records and social posts share one ordered stream: both carry
 -    // verified payload timestamps, so the same cursor pages across them.
 -    const verified = [...await listVerifiedRecords(root), ...await listVerifiedPosts(root)]
 +    const [records, posts, selection] = await Promise.all([
-       listVerifiedRecords(root), listLocalPostRecords(root), createFsStore(root).getSelection()
++      listVerifiedRecords(root), listVerifiedPosts(root), createFsStore(root).getSelection()
 +    ])
 +    const byId = new Map(records.map(entry => [entry.record.id, entry]))
 +    const visible = new Set([selection.repoId])
 +    for (let id = selection.updateId; id != null;) {
 +      requireThat(!visible.has(id) && byId.has(id), 'Incomplete selected update history')
 +      visible.add(id)
 +      const { previous, previousUpdate } = parseJson(byId.get(id).record.content)
 +      id = previous ?? previousUpdate
 +    }
 +    const shared = records.filter(({ record }) =>
-       visible.has(record.id) || parseJson(record.content)?.type === 'post')
++      visible.has(record.id))
 +    const verified = [...new Map([...shared, ...posts].map(entry => [entry.record.id, entry])).values()]
      verified.sort(compareRecords)
      const after = cursor
        ? verified.filter(({ record, timestamp }) =>

Git ยท Social feed