Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable pds appview indexing #1645

Merged
merged 39 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
48d45aa
rm indexing service
dholms Sep 19, 2023
1100756
remove message queue & refactor background queue
dholms Sep 19, 2023
3cc383c
wip
dholms Sep 19, 2023
9514a04
remove all canProxyReadc
dholms Sep 20, 2023
7e6bc46
finish cleanup
dholms Sep 20, 2023
c5291a5
clean up tests
dholms Sep 21, 2023
631d757
fix up tests
dholms Sep 21, 2023
e95cee7
fix api tests
dholms Sep 21, 2023
5c4fca3
fix build
dholms Sep 21, 2023
cce0efd
merge
dholms Sep 21, 2023
6e7fae7
fix compression test
dholms Sep 21, 2023
df3ecc6
update image tests
dholms Sep 21, 2023
edc4914
merge main
dholms Sep 21, 2023
00eca93
merge
dholms Sep 21, 2023
0fd089a
fix dev envs
dholms Sep 21, 2023
05add84
Merge branch 'disable-pds-appview-routes' into disable-pds-appview-in…
dholms Sep 21, 2023
acd5c20
build branch
dholms Sep 21, 2023
9ce9a49
wip - removing labeler
dholms Sep 22, 2023
ec422b0
fix service file
dholms Sep 22, 2023
182064b
remove kysely tables
dholms Sep 22, 2023
1d89005
re-enable getPopular
dholms Sep 22, 2023
cdc36db
format
dholms Sep 22, 2023
5ff5b42
cleaning up tests
dholms Sep 22, 2023
a6b4b4f
rm unused sharp code
dholms Sep 22, 2023
3e2c743
Merge branch 'disable-pds-appview-routes' into disable-pds-appview-in…
dholms Sep 22, 2023
8af6925
rm pds build
dholms Sep 22, 2023
f908d90
clean up tests
dholms Sep 22, 2023
222377b
fix build
dholms Sep 22, 2023
4a4f3cb
fix build
dholms Sep 22, 2023
c9994bd
migration
dholms Sep 22, 2023
be46a91
tidy
dholms Sep 22, 2023
d5965cc
merge main
dholms Sep 22, 2023
0f9d7f7
Merge branch 'main' into disable-pds-appview-indexing
dholms Sep 25, 2023
967c3a7
build branch
dholms Sep 25, 2023
16c950f
tidy
dholms Sep 25, 2023
2e09cc0
build branch
dholms Sep 25, 2023
c47f8b2
small tidy
dholms Sep 25, 2023
7a4e435
merge
dholms Sep 25, 2023
e10ba81
dont build
dholms Sep 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions packages/api/tests/agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ describe('agent', () => {

// put the agent through the auth flow
AtpAgent.configure({ fetch: tokenExpiredFetchHandler })
const res1 = await agent.api.app.bsky.feed.getTimeline()
const res1 = await createPost(agent)
AtpAgent.configure({ fetch: defaultFetchHandler })

expect(res1.success).toEqual(true)
Expand Down Expand Up @@ -267,9 +267,9 @@ describe('agent', () => {
// put the agent through the auth flow
AtpAgent.configure({ fetch: tokenExpiredFetchHandler })
const [res1, res2, res3] = await Promise.all([
agent.api.app.bsky.feed.getTimeline(),
agent.api.app.bsky.feed.getTimeline(),
agent.api.app.bsky.feed.getTimeline(),
createPost(agent),
createPost(agent),
createPost(agent),
])
AtpAgent.configure({ fetch: defaultFetchHandler })

Expand Down Expand Up @@ -462,3 +462,14 @@ describe('agent', () => {
})
})
})

const createPost = async (agent: AtpAgent) => {
return agent.api.com.atproto.repo.createRecord({
repo: agent.session?.did ?? '',
collection: 'app.bsky.feed.post',
record: {
text: 'hello there',
createdAt: new Date().toISOString(),
},
})
}
39 changes: 26 additions & 13 deletions packages/api/tests/bsky-agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ describe('agent', () => {
await close()
})

const getProfileDisplayName = async (
agent: BskyAgent,
): Promise<string | undefined> => {
try {
const res = await agent.api.app.bsky.actor.profile.get({
repo: agent.session?.did || '',
rkey: 'self',
})
return res.value.displayName ?? ''
} catch (err) {
return undefined
}
}

it('upsertProfile correctly creates and updates profiles.', async () => {
const agent = new BskyAgent({ service: server.url })

Expand All @@ -28,9 +42,8 @@ describe('agent', () => {
email: '[email protected]',
password: 'password',
})

const profile1 = await agent.getProfile({ actor: agent.session?.did || '' })
expect(profile1.data.displayName).toBeFalsy()
const displayName1 = await getProfileDisplayName(agent)
expect(displayName1).toBeFalsy()

await agent.upsertProfile((existing) => {
expect(existing).toBeFalsy()
Expand All @@ -39,8 +52,8 @@ describe('agent', () => {
}
})

const profile2 = await agent.getProfile({ actor: agent.session?.did || '' })
expect(profile2.data.displayName).toBe('Bob')
const displayName2 = await getProfileDisplayName(agent)
expect(displayName2).toBe('Bob')

await agent.upsertProfile((existing) => {
expect(existing).toBeTruthy()
Expand All @@ -49,8 +62,8 @@ describe('agent', () => {
}
})

const profile3 = await agent.getProfile({ actor: agent.session?.did || '' })
expect(profile3.data.displayName).toBe('BOB')
const displayName3 = await getProfileDisplayName(agent)
expect(displayName3).toBe('BOB')
})

it('upsertProfile correctly handles CAS failures.', async () => {
Expand All @@ -62,8 +75,8 @@ describe('agent', () => {
password: 'password',
})

const profile1 = await agent.getProfile({ actor: agent.session?.did || '' })
expect(profile1.data.displayName).toBeFalsy()
const displayName1 = await getProfileDisplayName(agent)
expect(displayName1).toBeFalsy()

let hasConflicted = false
let ranTwice = false
Expand All @@ -88,8 +101,8 @@ describe('agent', () => {
})
expect(ranTwice).toBe(true)

const profile2 = await agent.getProfile({ actor: agent.session?.did || '' })
expect(profile2.data.displayName).toBe('Bob')
const displayName2 = await getProfileDisplayName(agent)
expect(displayName2).toBe('Bob')
})

it('upsertProfile wont endlessly retry CAS failures.', async () => {
Expand All @@ -101,8 +114,8 @@ describe('agent', () => {
password: 'password',
})

const profile1 = await agent.getProfile({ actor: agent.session?.did || '' })
expect(profile1.data.displayName).toBeFalsy()
const displayName1 = await getProfileDisplayName(agent)
expect(displayName1).toBeFalsy()

const p = agent.upsertProfile(async (_existing) => {
await agent.com.atproto.repo.putRecord({
Expand Down
1 change: 0 additions & 1 deletion packages/bsky/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"http-errors": "^2.0.0",
"http-terminator": "^3.2.0",
"ioredis": "^5.3.2",
"iso-datestring-validator": "^2.2.2",
"kysely": "^0.22.0",
"multiformats": "^9.9.0",
"p-queue": "^6.6.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/bsky/src/services/indexing/plugins/block.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Selectable } from 'kysely'
import { AtUri } from '@atproto/syntax'
import { toSimplifiedISOSafe } from '@atproto/common'
import { CID } from 'multiformats/cid'
import * as Block from '../../../lexicon/types/app/bsky/graph/block'
import * as lex from '../../../lexicon/lexicons'
import { DatabaseSchema, DatabaseSchemaType } from '../../../db/database-schema'
import RecordProcessor from '../processor'
import { toSimplifiedISOSafe } from '../util'
import { PrimaryDatabase } from '../../../db'
import { BackgroundQueue } from '../../../background'
import { NotificationServer } from '../../../notifications'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Selectable } from 'kysely'
import { AtUri } from '@atproto/syntax'
import { toSimplifiedISOSafe } from '@atproto/common'
import { CID } from 'multiformats/cid'
import * as FeedGenerator from '../../../lexicon/types/app/bsky/feed/generator'
import * as lex from '../../../lexicon/lexicons'
import { PrimaryDatabase } from '../../../db'
import { DatabaseSchema, DatabaseSchemaType } from '../../../db/database-schema'
import { BackgroundQueue } from '../../../background'
import RecordProcessor from '../processor'
import { toSimplifiedISOSafe } from '../util'
import { NotificationServer } from '../../../notifications'

const lexId = lex.ids.AppBskyFeedGenerator
Expand Down
2 changes: 1 addition & 1 deletion packages/bsky/src/services/indexing/plugins/follow.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Selectable } from 'kysely'
import { AtUri } from '@atproto/syntax'
import { toSimplifiedISOSafe } from '@atproto/common'
import { CID } from 'multiformats/cid'
import * as Follow from '../../../lexicon/types/app/bsky/graph/follow'
import * as lex from '../../../lexicon/lexicons'
import { DatabaseSchema, DatabaseSchemaType } from '../../../db/database-schema'
import RecordProcessor from '../processor'
import { toSimplifiedISOSafe } from '../util'
import { PrimaryDatabase } from '../../../db'
import { countAll, excluded } from '../../../db/util'
import { BackgroundQueue } from '../../../background'
Expand Down
2 changes: 1 addition & 1 deletion packages/bsky/src/services/indexing/plugins/like.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Selectable } from 'kysely'
import { AtUri } from '@atproto/syntax'
import { toSimplifiedISOSafe } from '@atproto/common'
import { CID } from 'multiformats/cid'
import * as Like from '../../../lexicon/types/app/bsky/feed/like'
import * as lex from '../../../lexicon/lexicons'
import { DatabaseSchema, DatabaseSchemaType } from '../../../db/database-schema'
import RecordProcessor from '../processor'
import { toSimplifiedISOSafe } from '../util'
import { countAll, excluded } from '../../../db/util'
import { PrimaryDatabase } from '../../../db'
import { BackgroundQueue } from '../../../background'
Expand Down
2 changes: 1 addition & 1 deletion packages/bsky/src/services/indexing/plugins/list-block.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Selectable } from 'kysely'
import { AtUri } from '@atproto/syntax'
import { toSimplifiedISOSafe } from '@atproto/common'
import { CID } from 'multiformats/cid'
import * as ListBlock from '../../../lexicon/types/app/bsky/graph/listblock'
import * as lex from '../../../lexicon/lexicons'
Expand All @@ -8,7 +9,6 @@ import { DatabaseSchema, DatabaseSchemaType } from '../../../db/database-schema'
import RecordProcessor from '../processor'
import { BackgroundQueue } from '../../../background'
import { NotificationServer } from '../../../notifications'
import { toSimplifiedISOSafe } from '../util'

const lexId = lex.ids.AppBskyGraphListblock
type IndexedListBlock = Selectable<DatabaseSchemaType['list_block']>
Expand Down
2 changes: 1 addition & 1 deletion packages/bsky/src/services/indexing/plugins/list-item.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Selectable } from 'kysely'
import { AtUri } from '@atproto/syntax'
import { toSimplifiedISOSafe } from '@atproto/common'
import { CID } from 'multiformats/cid'
import * as ListItem from '../../../lexicon/types/app/bsky/graph/listitem'
import * as lex from '../../../lexicon/lexicons'
import { DatabaseSchema, DatabaseSchemaType } from '../../../db/database-schema'
import RecordProcessor from '../processor'
import { toSimplifiedISOSafe } from '../util'
import { InvalidRequestError } from '@atproto/xrpc-server'
import { PrimaryDatabase } from '../../../db'
import { BackgroundQueue } from '../../../background'
Expand Down
2 changes: 1 addition & 1 deletion packages/bsky/src/services/indexing/plugins/list.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Selectable } from 'kysely'
import { AtUri } from '@atproto/syntax'
import { toSimplifiedISOSafe } from '@atproto/common'
import { CID } from 'multiformats/cid'
import * as List from '../../../lexicon/types/app/bsky/graph/list'
import * as lex from '../../../lexicon/lexicons'
import { DatabaseSchema, DatabaseSchemaType } from '../../../db/database-schema'
import RecordProcessor from '../processor'
import { toSimplifiedISOSafe } from '../util'
import { PrimaryDatabase } from '../../../db'
import { BackgroundQueue } from '../../../background'
import { NotificationServer } from '../../../notifications'
Expand Down
2 changes: 1 addition & 1 deletion packages/bsky/src/services/indexing/plugins/post.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Insertable, Selectable, sql } from 'kysely'
import { CID } from 'multiformats/cid'
import { AtUri } from '@atproto/syntax'
import { toSimplifiedISOSafe } from '@atproto/common'
import { jsonStringToLex } from '@atproto/lexicon'
import {
Record as PostRecord,
Expand All @@ -19,7 +20,6 @@ import * as lex from '../../../lexicon/lexicons'
import { DatabaseSchema, DatabaseSchemaType } from '../../../db/database-schema'
import RecordProcessor from '../processor'
import { Notification } from '../../../db/tables/notification'
import { toSimplifiedISOSafe } from '../util'
import { PrimaryDatabase } from '../../../db'
import { countAll, excluded } from '../../../db/util'
import { BackgroundQueue } from '../../../background'
Expand Down
2 changes: 1 addition & 1 deletion packages/bsky/src/services/indexing/plugins/repost.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Selectable } from 'kysely'
import { CID } from 'multiformats/cid'
import { AtUri } from '@atproto/syntax'
import { toSimplifiedISOSafe } from '@atproto/common'
import * as Repost from '../../../lexicon/types/app/bsky/feed/repost'
import * as lex from '../../../lexicon/lexicons'
import { DatabaseSchema, DatabaseSchemaType } from '../../../db/database-schema'
import RecordProcessor from '../processor'
import { toSimplifiedISOSafe } from '../util'
import { PrimaryDatabase } from '../../../db'
import { countAll, excluded } from '../../../db/util'
import { BackgroundQueue } from '../../../background'
Expand Down
2 changes: 1 addition & 1 deletion packages/bsky/src/services/indexing/plugins/thread-gate.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { AtUri } from '@atproto/syntax'
import { InvalidRequestError } from '@atproto/xrpc-server'
import { toSimplifiedISOSafe } from '@atproto/common'
import { CID } from 'multiformats/cid'
import * as Threadgate from '../../../lexicon/types/app/bsky/feed/threadgate'
import * as lex from '../../../lexicon/lexicons'
import { DatabaseSchema, DatabaseSchemaType } from '../../../db/database-schema'
import RecordProcessor from '../processor'
import { toSimplifiedISOSafe } from '../util'
import { PrimaryDatabase } from '../../../db'
import { BackgroundQueue } from '../../../background'
import { NotificationServer } from '../../../notifications'
Expand Down
2 changes: 1 addition & 1 deletion packages/bsky/src/services/label/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { sql } from 'kysely'
import { AtUri } from '@atproto/syntax'
import { toSimplifiedISOSafe } from '@atproto/common'
import { Database } from '../../db'
import { Label, isSelfLabels } from '../../lexicon/types/com/atproto/label/defs'
import { ids } from '../../lexicon/lexicons'
import { toSimplifiedISOSafe } from '../indexing/util'
import { LabelCache } from '../../label-cache'

export type Labels = Record<string, Label[]>
Expand Down
1 change: 1 addition & 0 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@atproto/common-web": "workspace:^",
"@ipld/dag-cbor": "^7.0.3",
"cbor-x": "^1.5.1",
"iso-datestring-validator": "^2.2.2",
"multiformats": "^9.9.0",
"pino": "^8.15.0",
"zod": "3.21.4"
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from '@atproto/common-web'
export * from './dates'
export * from './fs'
export * from './ipld'
export * from './ipld-multi'
Expand Down
1 change: 0 additions & 1 deletion packages/dev-env/src/bin-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const run = async () => {
pds: {
port: 2583,
publicUrl: 'http://localhost:2583',
enableLabelsCache: true,
dbPostgresSchema: 'pds',
},
bsky: {
Expand Down
1 change: 0 additions & 1 deletion packages/dev-env/src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const run = async () => {
const network = await TestNetworkNoAppView.create({
pds: {
port: 2583,
enableLabelsCache: true,
publicUrl: 'http://localhost:2583',
},
plc: { port: 2582 },
Expand Down
48 changes: 24 additions & 24 deletions packages/dev-env/src/mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,30 +186,30 @@ export async function generateMockSetup(env: TestNetworkNoAppView) {
},
)

const ctx = env.pds.ctx
if (ctx) {
await ctx.db.db
.insertInto('label')
.values([
{
src: ctx.cfg.labelerDid,
uri: labeledPost.uri,
cid: labeledPost.cid,
val: 'nudity',
neg: 0,
cts: new Date().toISOString(),
},
{
src: ctx.cfg.labelerDid,
uri: filteredPost.uri,
cid: filteredPost.cid,
val: 'dmca-violation',
neg: 0,
cts: new Date().toISOString(),
},
])
.execute()
}
// const ctx = env.pds.ctx
// if (ctx) {
// await ctx.db.db
// .insertInto('label')
// .values([
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we nix this code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nixed the pds-only dev-env & switched this code to insert the labels into the appview 👌

// {
// src: ctx.cfg.labelerDid,
// uri: labeledPost.uri,
// cid: labeledPost.cid,
// val: 'nudity',
// neg: 0,
// cts: new Date().toISOString(),
// },
// {
// src: ctx.cfg.labelerDid,
// uri: filteredPost.uri,
// cid: filteredPost.cid,
// val: 'dmca-violation',
// neg: 0,
// cts: new Date().toISOString(),
// },
// ])
// .execute()
// }

// a set of replies
for (let i = 0; i < 100; i++) {
Expand Down
Loading