takeStar
uses tcmts.registry.stars, which uses tcmts.server.table, which uses tcmts.server.Table, which uses #tcm/host (database)
A star Jetstream sent: kept, to be checked against its writer's repository; or, deleted, gone once its repository
no longer holds it (checkStar).
import { STAR_COLLECTION, starOf } from "#codebase/tcmts/records"; import { checkStar, keepStar, safeLex, stars } from "#codebase/tcmts/registry"; import type { RegistryStar } from "#codebase/tcmts/registry"; import { enqueue } from "#codebase/tcmts/server"; import type { RawEvent } from "@bsky/jetstream"; export async function takeStar(e: RawEvent & { kind: "commit" }): Promise<void> { const uri = `at://${e.did}/${STAR_COLLECTION}/${e.commit.rkey}`; const had = await stars.findOne({ uri }); if (e.commit.operation === "delete") { if (had) enqueue(checkStar, uri); return; } const s = starOf( e.commit.rkey, e.commit.record instanceof Uint8Array ? safeLex(e.commit.record) : e.commit.record, ); if (!s) return; const row: RegistryStar = { uri, did: e.did, ...s, state: "pending" }; await keepStar(row); enqueue(checkStar, uri); }
uses
- tcmts.records.STAR_COLLECTION
- tcmts.records.starOf
- tcmts.registry.RegistryStar
- tcmts.registry.checkStar
- tcmts.registry.keepStar
- tcmts.registry.safeLex
- tcmts.registry.stars
- tcmts.server.enqueue