Skip to content

Commit

Permalink
remove custom feed harness from appview v2
Browse files Browse the repository at this point in the history
  • Loading branch information
devinivy committed Jan 31, 2024
1 parent 1eef487 commit 2f89746
Show file tree
Hide file tree
Showing 15 changed files with 226 additions and 211 deletions.
21 changes: 0 additions & 21 deletions packages/bsky/src/api/app/bsky/feed/describeFeedGenerator.ts

This file was deleted.

25 changes: 20 additions & 5 deletions packages/bsky/src/api/app/bsky/feed/getFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { QueryParams as GetFeedParams } from '../../../../lexicon/types/app/bsky
import { OutputSchema as SkeletonOutput } from '../../../../lexicon/types/app/bsky/feed/getFeedSkeleton'
import { Server } from '../../../../lexicon'
import AppContext from '../../../../context'
import { AlgoResponse, toFeedItem } from '../../../feed-gen/types'
import {
HydrationFnInput,
PresentationFnInput,
Expand Down Expand Up @@ -68,15 +67,12 @@ const skeleton = async (
): Promise<Skeleton> => {
const { ctx, params } = inputs
const timerSkele = new ServerTimer('skele').start()
const localAlgo = ctx.algos[params.feed]
const {
feedItems: algoItems,
cursor,
resHeaders,
...passthrough
} = localAlgo !== undefined
? await localAlgo(ctx, params, params.viewer)
: await skeletonFromFeedGen(ctx, params)
} = await skeletonFromFeedGen(ctx, params)

return {
cursor,
Expand Down Expand Up @@ -229,3 +225,22 @@ const skeletonFromFeedGen = async (

return { ...skele, resHeaders, feedItems }
}

export type AlgoResponse = {
feedItems: AlgoResponseItem[]
resHeaders?: Record<string, string>
cursor?: string
}

export type AlgoResponseItem = {
itemUri: string
postUri: string
}

export const toFeedItem = (feedItem: AlgoResponseItem): FeedItem => ({
post: { uri: feedItem.postUri },
repost:
feedItem.itemUri === feedItem.postUri
? undefined
: { uri: feedItem.itemUri },
})
30 changes: 0 additions & 30 deletions packages/bsky/src/api/app/bsky/feed/getFeedSkeleton.ts

This file was deleted.

29 changes: 0 additions & 29 deletions packages/bsky/src/api/app/bsky/unspecced/getTimelineSkeleton.ts

This file was deleted.

6 changes: 0 additions & 6 deletions packages/bsky/src/api/feed-gen/index.ts

This file was deleted.

45 changes: 0 additions & 45 deletions packages/bsky/src/api/feed-gen/types.ts

This file was deleted.

6 changes: 0 additions & 6 deletions packages/bsky/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { Server } from '../lexicon'
import AppContext from '../context'
import describeFeedGenerator from './app/bsky/feed/describeFeedGenerator'
import getTimeline from './app/bsky/feed/getTimeline'
import getActorFeeds from './app/bsky/feed/getActorFeeds'
import getSuggestedFeeds from './app/bsky/feed/getSuggestedFeeds'
import getAuthorFeed from './app/bsky/feed/getAuthorFeed'
import getFeed from './app/bsky/feed/getFeed'
import getFeedGenerator from './app/bsky/feed/getFeedGenerator'
import getFeedGenerators from './app/bsky/feed/getFeedGenerators'
import getFeedSkeleton from './app/bsky/feed/getFeedSkeleton'
import getLikes from './app/bsky/feed/getLikes'
import getListFeed from './app/bsky/feed/getListFeed'
import getPostThread from './app/bsky/feed/getPostThread'
Expand Down Expand Up @@ -40,7 +38,6 @@ import listNotifications from './app/bsky/notification/listNotifications'
import updateSeen from './app/bsky/notification/updateSeen'
import registerPush from './app/bsky/notification/registerPush'
import getPopularFeedGenerators from './app/bsky/unspecced/getPopularFeedGenerators'
import getTimelineSkeleton from './app/bsky/unspecced/getTimelineSkeleton'
import getTaggedSuggestions from './app/bsky/unspecced/getTaggedSuggestions'
import getSubjectStatus from './com/atproto/admin/getSubjectStatus'
import updateSubjectStatus from './com/atproto/admin/updateSubjectStatus'
Expand All @@ -57,15 +54,13 @@ export * as blobResolver from './blob-resolver'

export default function (server: Server, ctx: AppContext) {
// app.bsky
describeFeedGenerator(server, ctx)
getTimeline(server, ctx)
getActorFeeds(server, ctx)
getSuggestedFeeds(server, ctx)
getAuthorFeed(server, ctx)
getFeed(server, ctx)
getFeedGenerator(server, ctx)
getFeedGenerators(server, ctx)
getFeedSkeleton(server, ctx)
getLikes(server, ctx)
getListFeed(server, ctx)
getPostThread(server, ctx)
Expand Down Expand Up @@ -97,7 +92,6 @@ export default function (server: Server, ctx: AppContext) {
updateSeen(server, ctx)
registerPush(server, ctx)
getPopularFeedGenerators(server, ctx)
getTimelineSkeleton(server, ctx)
getTaggedSuggestions(server, ctx)
// com.atproto
getSubjectStatus(server, ctx)
Expand Down
7 changes: 0 additions & 7 deletions packages/bsky/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export interface ServerConfigValues {
port?: number
publicUrl?: string
serverDid: string
feedGenDid?: string
// external services
dataplaneUrls: string[]
dataplaneHttpVersion?: '1.1' | '2'
Expand Down Expand Up @@ -43,7 +42,6 @@ export class ServerConfig {
const debugMode = process.env.NODE_ENV !== 'production'
const publicUrl = process.env.BSKY_PUBLIC_URL || undefined
const serverDid = process.env.BSKY_SERVER_DID || 'did:example:test'
const feedGenDid = process.env.BSKY_FEED_GEN_DID
const envPort = parseInt(process.env.BSKY_PORT || '', 10)
const port = isNaN(envPort) ? 2584 : envPort
const didPlcUrl = process.env.BSKY_DID_PLC_URL || 'http://localhost:2582'
Expand Down Expand Up @@ -92,7 +90,6 @@ export class ServerConfig {
port,
publicUrl,
serverDid,
feedGenDid,
dataplaneUrls,
dataplaneHttpVersion,
dataplaneIgnoreBadTls,
Expand Down Expand Up @@ -149,10 +146,6 @@ export class ServerConfig {
return this.cfg.serverDid
}

get feedGenDid() {
return this.cfg.feedGenDid
}

get dataplaneUrls() {
return this.cfg.dataplaneUrls
}
Expand Down
6 changes: 0 additions & 6 deletions packages/bsky/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import AtpAgent from '@atproto/api'
import { Keypair } from '@atproto/crypto'
import { createServiceJwt } from '@atproto/xrpc-server'
import { ServerConfig } from './config'
import { MountedAlgos } from './api/feed-gen/types'
import { DataPlaneClient } from './data-plane/client'
import { Hydrator } from './hydration/hydrator'
import { Views } from './views'
Expand All @@ -24,7 +23,6 @@ export class AppContext {
idResolver: IdResolver
bsyncClient: BsyncClient
courierClient: CourierClient
algos: MountedAlgos
authVerifier: AuthVerifier
},
) {}
Expand Down Expand Up @@ -81,10 +79,6 @@ export class AppContext {
keypair: this.signingKey,
})
}

get algos(): MountedAlgos {
return this.opts.algos
}
}

export default AppContext
7 changes: 1 addition & 6 deletions packages/bsky/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { createServer } from './lexicon'
import { ImageUriBuilder } from './image/uri'
import { BlobDiskCache, ImageProcessingServer } from './image/server'
import AppContext from './context'
import { MountedAlgos } from './api/feed-gen/types'
import { Keypair } from '@atproto/crypto'
import { createDataPlaneClient } from './data-plane/client'
import { Hydrator } from './hydration/hydrator'
Expand All @@ -26,12 +25,10 @@ import { authWithApiKey as courierAuth, createCourierClient } from './courier'

export * from './data-plane'
export type { ServerConfigValues } from './config'
export type { MountedAlgos } from './api/feed-gen/types'
export { ServerConfig } from './config'
export { Database } from './data-plane/server/db'
export { Redis } from './redis'
export { AppContext } from './context'
export { makeAlgos } from './api/feed-gen'

export class BskyAppView {
public ctx: AppContext
Expand All @@ -47,9 +44,8 @@ export class BskyAppView {
static create(opts: {
config: ServerConfig
signingKey: Keypair
algos?: MountedAlgos
}): BskyAppView {
const { config, signingKey, algos = {} } = opts
const { config, signingKey } = opts
const app = express()
app.use(cors())
app.use(loggerMiddleware)
Expand Down Expand Up @@ -119,7 +115,6 @@ export class BskyAppView {
bsyncClient,
courierClient,
authVerifier,
algos,
})

let server = createServer({
Expand Down
6 changes: 0 additions & 6 deletions packages/bsky/tests/feed-generation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ describe('feed generation', () => {
await network.close()
})

// @TODO enable once getFeed is implemented
it('describes the feed generator', async () => {
const res = await agent.api.app.bsky.feed.describeFeedGenerator()
expect(res.data.did).toBe(network.bsky.ctx.cfg.feedGenDid)
})

it('feed gen records can be created.', async () => {
const all = await pdsAgent.api.app.bsky.feed.generator.create(
{ repo: alice, rkey: 'all' },
Expand Down
2 changes: 0 additions & 2 deletions packages/dev-env/src/bsky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export class TestBsky {
labelsFromIssuerDids: ['did:example:labeler'], // this did is also used as the labeler in seeds
...cfg,
adminPasswords: [ADMIN_PASSWORD, MOD_PASSWORD, TRIAGE_PASSWORD],
feedGenDid: 'did:example:feedGen',
})

// Separate migration db in case migration changes some connection state that we need in the tests, e.g. "alter database ... set ..."
Expand All @@ -84,7 +83,6 @@ export class TestBsky {
const server = bsky.BskyAppView.create({
config,
signingKey: serviceKeypair,
algos: cfg.algos,
})

const sub = new bsky.RepoSubscription({
Expand Down
1 change: 0 additions & 1 deletion packages/dev-env/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export type BskyConfig = Partial<bsky.ServerConfig> & {
redisHost: string
pdsPort: number
migration?: string
algos?: bsky.MountedAlgos
}

export type BsyncConfig = Partial<bsync.ServerEnvironment> & {
Expand Down
Loading

0 comments on commit 2f89746

Please sign in to comment.