From bb79ce2f1485d83aaf3b0ee401df0ac225cc61e0 Mon Sep 17 00:00:00 2001 From: Roscoe Rubin-Rottenberg Date: Wed, 18 Feb 2026 12:39:01 -0500 Subject: [PATCH] revert stories archive --- api/index.ts | 2 - api/so/sprk/story/getArchive.ts | 143 ---------------- data-plane/db/index.ts | 4 - data-plane/db/models.ts | 34 ---- data-plane/indexing/plugins/story.ts | 1 - data-plane/indexing/processor.ts | 23 --- data-plane/routes/records.ts | 48 ------ data-plane/routes/stories.ts | 62 ------- hydration/story.ts | 20 --- lex/index.ts | 13 -- lex/lexicons.ts | 47 ------ lex/types/so/sprk/story/getArchive.ts | 30 ---- lexicons/so/sprk/story/getArchive.json | 36 ---- tests/stories_test.ts | 219 ------------------------- tests/util.ts | 4 - 15 files changed, 686 deletions(-) delete mode 100644 api/so/sprk/story/getArchive.ts delete mode 100644 lex/types/so/sprk/story/getArchive.ts delete mode 100644 lexicons/so/sprk/story/getArchive.json diff --git a/api/index.ts b/api/index.ts index 8a7471f..f08ce2f 100644 --- a/api/index.ts +++ b/api/index.ts @@ -21,7 +21,6 @@ import getRecord from "./com/atproto/repo/getRecord.ts"; import resolveHandle from "./com/atproto/identity/resolveHandle.ts"; import getStories from "./so/sprk/story/getStories.ts"; import getStoriesTimeline from "./so/sprk/story/getTimeline.ts"; -import getStoriesArchive from "./so/sprk/story/getArchive.ts"; import getProfiles from "./so/sprk/actor/getProfiles.ts"; import searchPosts from "./so/sprk/feed/searchPosts.ts"; import getActorAudios from "./so/sprk/sound/getActorAudios.ts"; @@ -61,7 +60,6 @@ export default function (server: Server, ctx: AppContext) { resolveHandle(server, ctx); getStories(server, ctx); getStoriesTimeline(server, ctx); - getStoriesArchive(server, ctx); searchPosts(server, ctx); getActorAudios(server, ctx); getTrendingAudios(server, ctx); diff --git a/api/so/sprk/story/getArchive.ts b/api/so/sprk/story/getArchive.ts deleted file mode 100644 index 064a2e5..0000000 --- a/api/so/sprk/story/getArchive.ts +++ /dev/null @@ -1,143 +0,0 @@ -import { InvalidRequestError } from "@atp/xrpc-server"; -import { mapDefined } from "@atp/common"; -import { AppContext } from "../../../../context.ts"; -import { HydrateCtx, HydrationState } from "../../../../hydration/index.ts"; -import { parseString } from "../../../../hydration/util.ts"; -import { Server } from "../../../../lex/index.ts"; -import { - OutputSchema, - QueryParams, -} from "../../../../lex/types/so/sprk/story/getArchive.ts"; -import { - createPipeline, - HydrationFnInput, - PresentationFnInput, - RulesFnInput, - SkeletonFnInput, -} from "../../../../pipeline.ts"; -import { uriToDid } from "../../../../utils/uris.ts"; -import { resHeaders } from "../../../util.ts"; - -const MAX_LIMIT = 100; -const DEFAULT_LIMIT = 50; - -export default function (server: Server, ctx: AppContext) { - const getArchive = createPipeline(skeleton, hydration, rules, presentation); - server.so.sprk.story.getArchive({ - auth: ctx.authVerifier.standard, - handler: async ({ params, auth, req }) => { - const { includeTakedowns } = ctx.authVerifier.parseCreds(auth); - const viewer = auth.credentials.iss; - const labelers = ctx.reqLabelers(req); - const hydrateCtx = await ctx.hydrator.createContext({ - viewer, - labelers, - includeTakedowns, - }); - - const { limit: limitParam = DEFAULT_LIMIT, cursor } = params; - const limit = typeof limitParam === "string" - ? parseInt(limitParam, 10) - : limitParam; - - if (isNaN(limit) || limit < 1 || limit > MAX_LIMIT) { - throw new InvalidRequestError( - `Invalid limit: must be between 1 and ${MAX_LIMIT}`, - ); - } - - const [result, repoRev] = await Promise.all([ - getArchive( - { - ...params, - limit, - cursor, - hydrateCtx: hydrateCtx.copy({ viewer, includeTakedowns }), - }, - ctx, - ), - ctx.hydrator.actor.getRepoRevSafe(viewer), - ]); - - return { - encoding: "application/json", - body: result, - headers: resHeaders({ - repoRev, - labelers: hydrateCtx.labelers, - }), - }; - }, - }); -} - -const skeleton = async ( - inputs: SkeletonFnInput, -): Promise => { - const { ctx, params } = inputs; - const viewer = params.hydrateCtx.viewer!; - const res = await ctx.dataplane.stories.getArchive( - viewer, - params.limit, - params.cursor, - params.hydrateCtx.includeTakedowns || false, - ); - - return { - stories: res.stories.map((story) => story.uri), - cursor: parseString(res.cursor), - }; -}; - -const hydration = async ( - inputs: HydrationFnInput, -): Promise => { - const { ctx, params, skeleton } = inputs; - const authorDids = [...new Set(skeleton.stories.map((uri) => uriToDid(uri)))]; - - const [stories, actors] = await Promise.all([ - ctx.hydrator.story.getArchivedStories( - skeleton.stories, - params.hydrateCtx.includeTakedowns || false, - ), - ctx.hydrator.actor.getActors(authorDids, params.hydrateCtx), - ]); - - return { - stories, - actors, - }; -}; - -const rules = (inputs: RulesFnInput): Skeleton => { - const { skeleton, hydration } = inputs; - const availableStories = skeleton.stories.filter((uri) => { - return Boolean(hydration.stories?.get(uri)); - }); - return { stories: availableStories, cursor: skeleton.cursor }; -}; - -const presentation = ( - inputs: PresentationFnInput, -): OutputSchema => { - const { ctx, skeleton, hydration } = inputs; - const storyViews = mapDefined(skeleton.stories, (uri) => { - return ctx.views.story(uri, hydration); - }); - return { - stories: storyViews, - ...(skeleton.cursor && { cursor: skeleton.cursor }), - }; -}; - -type Context = AppContext; - -type Params = QueryParams & { - hydrateCtx: HydrateCtx & { viewer: string }; - limit: number; -}; - -type Skeleton = { - stories: string[]; - cursor?: string; -}; diff --git a/data-plane/db/index.ts b/data-plane/db/index.ts index 87301d7..30363fa 100644 --- a/data-plane/db/index.ts +++ b/data-plane/db/index.ts @@ -55,10 +55,6 @@ export class Database { "Record", models.recordSchema, ), - ArchivedRecord: this.connection.model( - "ArchivedRecord", - models.archivedRecordSchema, - ), DuplicateRecord: this.connection.model( "DuplicateRecord", models.duplicateRecordSchema, diff --git a/data-plane/db/models.ts b/data-plane/db/models.ts index 9b2a1d4..944d8f7 100644 --- a/data-plane/db/models.ts +++ b/data-plane/db/models.ts @@ -114,20 +114,6 @@ export interface RecordDocument { takedownRef: string; invalidReplyRoot?: boolean; } - -export interface ArchivedRecordDocument { - uri: string; - cid: string; - did: string; - collectionName: string; - rkey: string; - createdAt: string; - indexedAt: string; - json: string; - archivedAt: string; - deleteReason: "user_delete" | "takedown"; - takedownRef?: string; -} export const recordSchema = new Schema({ uri: { type: String, required: true, unique: true, index: true }, cid: { type: String, required: true }, @@ -142,25 +128,6 @@ export const recordSchema = new Schema({ invalidReplyRoot: { type: Boolean, required: false }, }); -export const archivedRecordSchema = new Schema({ - uri: { type: String, required: true, unique: true, index: true }, - cid: { type: String, required: true }, - did: { type: String, required: true, index: true }, - collectionName: { type: String, required: true, index: true }, - rkey: { type: String, required: true }, - createdAt: { type: String, required: true }, - indexedAt: { type: String, required: true }, - json: { type: String, required: true }, - archivedAt: { type: String, required: true }, - deleteReason: { - type: String, - required: true, - enum: ["user_delete", "takedown"], - }, - takedownRef: { type: String, required: false }, -}) - .index({ did: 1, collectionName: 1, indexedAt: -1 }); - // duplicate records export interface DuplicateRecordDocument { @@ -699,7 +666,6 @@ export const pushTokenSchema = new Schema({ export interface DatabaseModels { Record: Model; - ArchivedRecord: Model; DuplicateRecord: Model; Like: Model; Post: Model; diff --git a/data-plane/indexing/plugins/story.ts b/data-plane/indexing/plugins/story.ts index b37e68e..34ca51d 100644 --- a/data-plane/indexing/plugins/story.ts +++ b/data-plane/indexing/plugins/story.ts @@ -70,7 +70,6 @@ export const makePlugin = ( insertFn, findDuplicate, deleteFn, - archiveOnDelete: true, notifsForInsert, notifsForDelete, }); diff --git a/data-plane/indexing/processor.ts b/data-plane/indexing/processor.ts index c45a070..ac30d95 100644 --- a/data-plane/indexing/processor.ts +++ b/data-plane/indexing/processor.ts @@ -30,7 +30,6 @@ type RecordProcessorParams = { replacedBy: S | null, ) => { notifs: Notif[]; toDelete: string[] }; updateAggregates?: (db: Database, obj: S) => Promise; - archiveOnDelete?: boolean; }; type Notif = { @@ -247,28 +246,6 @@ export class RecordProcessor { async deleteRecord(uri: AtUri, cascading = false) { const uriStr = uri.toString(); - const record = await this.db.models.Record.findOne({ uri: uriStr }).lean(); - - if (record && this.params.archiveOnDelete) { - const isTakedown = !!record.takedownRef; - await this.db.models.ArchivedRecord.findOneAndUpdate( - { uri: uriStr }, - { - uri: record.uri, - cid: record.cid, - did: record.did, - collectionName: record.collectionName, - rkey: record.rkey, - createdAt: record.createdAt, - indexedAt: record.indexedAt, - json: record.json, - archivedAt: new Date().toISOString(), - deleteReason: isTakedown ? "takedown" : "user_delete", - takedownRef: record.takedownRef || undefined, - }, - { upsert: true, new: true }, - ); - } await this.db.models.Record.deleteOne({ uri: uriStr }); await this.db.models.DuplicateRecord.deleteOne({ uri: uriStr }); diff --git a/data-plane/routes/records.ts b/data-plane/routes/records.ts index a391306..3acfa4b 100644 --- a/data-plane/routes/records.ts +++ b/data-plane/routes/records.ts @@ -60,49 +60,6 @@ export async function getRecords( return { records }; } -export async function getArchivedRecords( - db: Database, - uris: string[], - collection?: string, -): Promise<{ - records: Array; -}> { - const validUris = collection - ? uris.filter((uri) => new AtUri(uri).collection === collection) - : uris; - - const res = validUris.length - ? await db.models.ArchivedRecord.find({ - uri: { $in: validUris }, - }) - : []; - - const byUri = keyBy(res, "uri"); - - const records: Record[] = uris.map((uri) => { - const row = byUri.get(uri); - const createdAt = row?.createdAt - ? new Date(row.createdAt).toISOString() - : undefined; - const indexedAt = row?.indexedAt - ? new Date(row.indexedAt).toISOString() - : undefined; - - return { - record: row?.json ?? JSON.stringify(null), - uri, - cid: row?.cid, - createdAt, - indexedAt, - sortedAt: compositeTime(createdAt, indexedAt), - takenDown: !!row?.takedownRef, - takedownRef: row?.takedownRef || undefined, - }; - }); - - return { records }; -} - // Helper function to get post records with metadata async function getPostRecords( db: Database, @@ -202,9 +159,4 @@ export class Records { const result = await getRecords(this.db, uris, ids.SoSprkStoryPost); return result; } - - async getArchivedStoryRecords(uris: string[]) { - const result = await getArchivedRecords(this.db, uris, ids.SoSprkStoryPost); - return result; - } } diff --git a/data-plane/routes/stories.ts b/data-plane/routes/stories.ts index 48f1687..22fbe27 100644 --- a/data-plane/routes/stories.ts +++ b/data-plane/routes/stories.ts @@ -1,7 +1,6 @@ import { Database } from "../db/index.ts"; import { TimeCidKeyset } from "../db/pagination.ts"; import { compositeTime } from "../util.ts"; -import { ids } from "../../lex/lexicons.ts"; const STORIES_EXPIRY_HOURS = 24; @@ -126,67 +125,6 @@ export class Stories { }; } - /** - * Get archived stories for an author - */ - async getArchive( - actorDid: string, - limit = 50, - cursor?: string, - includeTakedowns = false, - ): Promise<{ stories: StoryItem[]; cursor?: string }> { - const baseQuery: { - did: string; - collectionName: string; - $or?: Array< - { takedownRef?: { $exists: boolean } } | { takedownRef: string } - >; - } = { - did: actorDid, - collectionName: ids.SoSprkStoryPost, - }; - - if (!includeTakedowns) { - baseQuery.$or = [ - { takedownRef: { $exists: false } }, - { takedownRef: "" }, - ]; - } - - const storiesQuery = this.db.models.ArchivedRecord.find(baseQuery); - - const paginatedQuery = this.timeCidKeyset.paginate(storiesQuery, { - limit: limit + 1, - cursor, - direction: "desc", - }); - - const stories = await paginatedQuery.exec(); - const hasMore = stories.length > limit; - const resultStories = hasMore ? stories.slice(0, limit) : stories; - - const transformedStories: StoryItem[] = resultStories.map((story) => ({ - uri: story.uri, - cid: story.cid, - authorDid: story.did, - createdAt: story.createdAt, - indexedAt: story.indexedAt, - archived: true, - sortAt: compositeTime(story.createdAt, story.indexedAt) || - story.createdAt, - })); - - let nextCursor: string | undefined; - if (hasMore && resultStories.length > 0) { - nextCursor = this.timeCidKeyset.packFromResult(resultStories); - } - - return { - stories: transformedStories, - cursor: nextCursor, - }; - } - /** * Filter out expired stories (older than 24 hours) */ diff --git a/hydration/story.ts b/hydration/story.ts index b25e7cb..8c151bf 100644 --- a/hydration/story.ts +++ b/hydration/story.ts @@ -29,24 +29,4 @@ export class StoryHydrator { ); }, base); } - - async getArchivedStories( - uris: string[], - includeTakedowns = false, - given = new HydrationMap(), - ): Promise { - const [have, need] = split(uris, (uri) => given.has(uri)); - const base = have.reduce( - (acc, uri) => acc.set(uri, given.get(uri) ?? null), - new HydrationMap(), - ); - if (!need.length) return base; - - const res = await this.dataplane.records.getArchivedStoryRecords(need); - - return need.reduce((acc, uri, i) => { - const record = parseRecord(res.records[i], includeTakedowns); - return acc.set(uri, record ?? null); - }, base); - } } diff --git a/lex/index.ts b/lex/index.ts index 40062cc..23c9e74 100644 --- a/lex/index.ts +++ b/lex/index.ts @@ -216,7 +216,6 @@ import type * as SoSprkActorSearchActors from "./types/so/sprk/actor/searchActor import type * as SoSprkActorGetProfiles from "./types/so/sprk/actor/getProfiles.ts"; import type * as SoSprkActorGetPreferences from "./types/so/sprk/actor/getPreferences.ts"; import type * as SoSprkStoryGetTimeline from "./types/so/sprk/story/getTimeline.ts"; -import type * as SoSprkStoryGetArchive from "./types/so/sprk/story/getArchive.ts"; import type * as SoSprkStoryGetStories from "./types/so/sprk/story/getStories.ts"; import type * as SoSprkLabelerGetServices from "./types/so/sprk/labeler/getServices.ts"; import type * as ComAtprotoTempDereferenceScope from "./types/com/atproto/temp/dereferenceScope.ts"; @@ -3317,18 +3316,6 @@ export class SoSprkStoryNS { return this._server.xrpc.method(nsid, cfg); } - getArchive( - cfg: MethodConfigOrHandler< - A, - SoSprkStoryGetArchive.QueryParams, - SoSprkStoryGetArchive.HandlerInput, - SoSprkStoryGetArchive.HandlerOutput - >, - ) { - const nsid = "so.sprk.story.getArchive"; // @ts-ignore - dynamically generated - return this._server.xrpc.method(nsid, cfg); - } - getStories( cfg: MethodConfigOrHandler< A, diff --git a/lex/lexicons.ts b/lex/lexicons.ts index 6300d2a..1694d27 100644 --- a/lex/lexicons.ts +++ b/lex/lexicons.ts @@ -20753,52 +20753,6 @@ export const schemaDict = { }, }, }, - "SoSprkStoryGetArchive": { - "lexicon": 1, - "id": "so.sprk.story.getArchive", - "defs": { - "main": { - "type": "query", - "description": - "Get archived stories for the requesting account. Requires auth.", - "parameters": { - "type": "params", - "properties": { - "limit": { - "type": "integer", - "minimum": 1, - "maximum": 100, - "default": 50, - }, - "cursor": { - "type": "string", - }, - }, - }, - "output": { - "encoding": "application/json", - "schema": { - "type": "object", - "required": [ - "stories", - ], - "properties": { - "cursor": { - "type": "string", - }, - "stories": { - "type": "array", - "items": { - "type": "ref", - "ref": "lex:so.sprk.story.defs#storyView", - }, - }, - }, - }, - }, - }, - }, - }, "SoSprkStoryGetStories": { "lexicon": 1, "id": "so.sprk.story.getStories", @@ -26935,7 +26889,6 @@ export const ids = { SoSprkActorProfile: "so.sprk.actor.profile", SoSprkStoryDefs: "so.sprk.story.defs", SoSprkStoryGetTimeline: "so.sprk.story.getTimeline", - SoSprkStoryGetArchive: "so.sprk.story.getArchive", SoSprkStoryGetStories: "so.sprk.story.getStories", SoSprkStoryPost: "so.sprk.story.post", SoSprkLabelerDefs: "so.sprk.labeler.defs", diff --git a/lex/types/so/sprk/story/getArchive.ts b/lex/types/so/sprk/story/getArchive.ts deleted file mode 100644 index 5c7feaa..0000000 --- a/lex/types/so/sprk/story/getArchive.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * GENERATED CODE - DO NOT MODIFY - */ -import type * as SoSprkStoryDefs from "./defs.ts"; - -export type QueryParams = { - limit: number; - cursor?: string; -}; -export type InputSchema = undefined; - -export interface OutputSchema { - cursor?: string; - stories: (SoSprkStoryDefs.StoryView)[]; -} - -export type HandlerInput = void; - -export interface HandlerSuccess { - encoding: "application/json"; - body: OutputSchema; - headers?: { [key: string]: string }; -} - -export interface HandlerError { - status: number; - message?: string; -} - -export type HandlerOutput = HandlerError | HandlerSuccess; diff --git a/lexicons/so/sprk/story/getArchive.json b/lexicons/so/sprk/story/getArchive.json deleted file mode 100644 index eef8777..0000000 --- a/lexicons/so/sprk/story/getArchive.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "lexicon": 1, - "id": "so.sprk.story.getArchive", - "defs": { - "main": { - "type": "query", - "description": "Get archived stories for the requesting account. Requires auth.", - "parameters": { - "type": "params", - "properties": { - "limit": { - "type": "integer", - "minimum": 1, - "maximum": 100, - "default": 50 - }, - "cursor": { "type": "string" } - } - }, - "output": { - "encoding": "application/json", - "schema": { - "type": "object", - "required": ["stories"], - "properties": { - "cursor": { "type": "string" }, - "stories": { - "type": "array", - "items": { "type": "ref", "ref": "so.sprk.story.defs#storyView" } - } - } - } - } - } - } -} diff --git a/tests/stories_test.ts b/tests/stories_test.ts index 0e36268..aa616df 100644 --- a/tests/stories_test.ts +++ b/tests/stories_test.ts @@ -4,24 +4,6 @@ import { createTestContext, TEST_USERS } from "./util.ts"; const VALID_BLOB_CID = "bafyreihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku"; -const storyRecordJson = (createdAt: string) => { - return JSON.stringify({ - $type: "so.sprk.story.post", - createdAt, - media: { - $type: "so.sprk.media.image", - image: { - $type: "blob", - ref: { $link: VALID_BLOB_CID }, - mimeType: "image/jpeg", - size: 250000, - }, - alt: "Archived story image", - aspectRatio: { width: 1080, height: 1920 }, - }, - }); -}; - Deno.test({ name: "Stories", sanitizeOps: false, @@ -116,206 +98,5 @@ Deno.test({ } }, ); - - await t.step( - "getArchive excludes takedown archived stories by default", - async () => { - const { ctx, cleanup } = await createTestContext({ - actors: false, - profiles: false, - posts: false, - replies: false, - stories: false, - likes: false, - reposts: false, - follows: false, - blocks: false, - audio: false, - generators: false, - preferences: false, - records: false, - actorSync: false, - }); - - try { - const now = new Date().toISOString(); - const archivedUri = `at://${ - TEST_USERS[0].did - }/so.sprk.story.post/story1`; - const takedownArchivedUri = `at://${ - TEST_USERS[0].did - }/so.sprk.story.post/story-takedown`; - const otherAuthorArchivedUri = `at://${ - TEST_USERS[2].did - }/so.sprk.story.post/story2`; - - await ctx.db.models.ArchivedRecord.create({ - uri: archivedUri, - cid: "bafyreihivhfhv6rh4x4a4znkqrvqwp5xw4xvqjqstory1", - did: TEST_USERS[0].did, - collectionName: "so.sprk.story.post", - rkey: "story1", - createdAt: now, - indexedAt: now, - json: storyRecordJson(now), - archivedAt: now, - deleteReason: "user_delete", - }); - await ctx.db.models.ArchivedRecord.create({ - uri: takedownArchivedUri, - cid: "bafyreihivhfhv6rh4x4a4znkqrvqwp5xw4xvqjqstorytakedown", - did: TEST_USERS[0].did, - collectionName: "so.sprk.story.post", - rkey: "story-takedown", - createdAt: now, - indexedAt: now, - json: storyRecordJson(now), - archivedAt: now, - deleteReason: "takedown", - takedownRef: "SPRK-TAKEDOWN-1", - }); - await ctx.db.models.ArchivedRecord.create({ - uri: otherAuthorArchivedUri, - cid: "bafyreihivhfhv6rh4x4a4znkqrvqwp5xw4xvqjqstory2", - did: TEST_USERS[2].did, - collectionName: "so.sprk.story.post", - rkey: "story2", - createdAt: now, - indexedAt: now, - json: storyRecordJson(now), - archivedAt: now, - deleteReason: "user_delete", - }); - - const res = await ctx.dataplane.stories.getArchive( - TEST_USERS[0].did, - 10, - ); - - assertEquals(res.stories.length, 1); - assertEquals(res.stories[0].uri, archivedUri); - assertEquals(res.stories[0].archived, true); - assertEquals(res.cursor, undefined); - - const resIncludingTakedowns = await ctx.dataplane.stories.getArchive( - TEST_USERS[0].did, - 10, - undefined, - true, - ); - assertEquals(resIncludingTakedowns.stories.length, 2); - } finally { - await cleanup(); - } - }, - ); - - await t.step( - "getArchivedStories hydrates from archived records", - async () => { - const { ctx, cleanup } = await createTestContext({ - actors: false, - profiles: false, - posts: false, - replies: false, - stories: false, - likes: false, - reposts: false, - follows: false, - blocks: false, - audio: false, - generators: false, - preferences: false, - records: false, - actorSync: false, - }); - - try { - const now = new Date().toISOString(); - const archivedUri = `at://${ - TEST_USERS[0].did - }/so.sprk.story.post/story1`; - const missingUri = `at://${ - TEST_USERS[2].did - }/so.sprk.story.post/story2`; - - await ctx.db.models.ArchivedRecord.create({ - uri: archivedUri, - cid: "bafyreihivhfhv6rh4x4a4znkqrvqwp5xw4xvqjqstory3", - did: TEST_USERS[0].did, - collectionName: "so.sprk.story.post", - rkey: "story1", - createdAt: now, - indexedAt: now, - json: storyRecordJson(now), - archivedAt: now, - deleteReason: "user_delete", - }); - - const hydrated = await ctx.hydrator.story.getArchivedStories([ - archivedUri, - missingUri, - ]); - - assertEquals(Boolean(hydrated.get(archivedUri)), true); - assertEquals(hydrated.get(missingUri), null); - } finally { - await cleanup(); - } - }, - ); - - await t.step("getArchivedStories applies takedown filtering", async () => { - const { ctx, cleanup } = await createTestContext({ - actors: false, - profiles: false, - posts: false, - replies: false, - stories: false, - likes: false, - reposts: false, - follows: false, - blocks: false, - audio: false, - generators: false, - preferences: false, - records: false, - actorSync: false, - }); - - try { - const now = new Date().toISOString(); - const takedownUri = `at://${ - TEST_USERS[0].did - }/so.sprk.story.post/story-takedown`; - - await ctx.db.models.ArchivedRecord.create({ - uri: takedownUri, - cid: "bafyreihivhfhv6rh4x4a4znkqrvqwp5xw4xvqjqstory4", - did: TEST_USERS[0].did, - collectionName: "so.sprk.story.post", - rkey: "story-takedown", - createdAt: now, - indexedAt: now, - json: storyRecordJson(now), - archivedAt: now, - deleteReason: "user_delete", - takedownRef: "SPRK-TAKEDOWN-1", - }); - - const hidden = await ctx.hydrator.story.getArchivedStories([ - takedownUri, - ]); - assertEquals(hidden.get(takedownUri), null); - - const included = await ctx.hydrator.story.getArchivedStories( - [takedownUri], - true, - ); - assertEquals(Boolean(included.get(takedownUri)), true); - } finally { - await cleanup(); - } - }); }, }); diff --git a/tests/util.ts b/tests/util.ts index fe0dc89..3532198 100644 --- a/tests/util.ts +++ b/tests/util.ts @@ -140,10 +140,6 @@ export async function createTestDatabase( "Record", models.recordSchema, ), - ArchivedRecord: connection.model( - "ArchivedRecord", - models.archivedRecordSchema, - ), DuplicateRecord: connection.model( "DuplicateRecord", models.duplicateRecordSchema, -- 2.51.2