anbot

174e82a / sync.mjs

View file at this commit

diff --cc sync.mjs
index a1795a0,9ca714b..5f03852
--- a/sync.mjs
+++ b/sync.mjs
@@@ -150,11 -160,8 +160,10 @@@ export async function pull(store, baseU
      repoId = repos[0].record.id
    }
  
 +  const publisher = recordAuthor(repos.find(({ record }) => record.id === repoId).record)
    const held = verified.filter(({ record, body }) =>
 -    (isGitRepo(body) && record.id === repoId) || belongsToRepo(body, repoId))
 +    (isGitRepo(body) && record.id === repoId) ||
-     (belongsToRepo(body, repoId) && recordAuthor(record) === publisher) ||
-     (body?.anbot === 1 && body.type === 'post'))
++    (belongsToRepo(body, repoId) && recordAuthor(record) === publisher))
    // Snapshot what was already held before storing: the chain walk stops at
    // records held before this pull, not at records this pull just stored.
    const heldBefore = new Set()
@@@ -167,9 -173,19 +175,19 @@@
      if (await store.putRecord(record.id, utf8Encode(JSON.stringify(record)))) stored++
    }
  
+   // Posts replicate independently of the git chain: verify each post's
+   // shape, store it through the post operations, and never let it touch
+   // the chain walk or the selection below.
+   let posts = 0
+   for (const { record, body } of verified) {
+     if (!isPost(body)) continue
+     await verifyPost(record)
+     if (await store.putPost(record.id, utf8Encode(JSON.stringify(record)))) posts++
+   }
+ 
    const updates = []
    for (const entry of verified) {
 -    if (!isGitUpdate(entry.body, repoId)) continue
 +    if (!isGitUpdate(entry.body, repoId) || recordAuthor(entry.record) !== publisher) continue
      updates.push({ ...entry, timestamp: envelopeTimestamp(entry.record.signature) })
    }
    requireThat(updates.length > 0, 'Remote has no updates')

Git ยท Social feed