Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Sep 27, 2023
2 parents 33db3db + 6271198 commit a903798
Show file tree
Hide file tree
Showing 32 changed files with 208 additions and 525 deletions.
21 changes: 0 additions & 21 deletions lexicons/com/atproto/temp/upgradeRepoVersion.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@atproto/api",
"version": "0.6.18",
"version": "0.6.19",
"license": "MIT",
"description": "Client library for atproto and Bluesky",
"keywords": [
Expand Down
23 changes: 0 additions & 23 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ import * as ComAtprotoSyncListRepos from './types/com/atproto/sync/listRepos'
import * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOfUpdate'
import * as ComAtprotoSyncRequestCrawl from './types/com/atproto/sync/requestCrawl'
import * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscribeRepos'
import * as ComAtprotoTempUpgradeRepoVersion from './types/com/atproto/temp/upgradeRepoVersion'
import * as AppBskyActorDefs from './types/app/bsky/actor/defs'
import * as AppBskyActorGetPreferences from './types/app/bsky/actor/getPreferences'
import * as AppBskyActorGetProfile from './types/app/bsky/actor/getProfile'
Expand Down Expand Up @@ -200,7 +199,6 @@ export * as ComAtprotoSyncListRepos from './types/com/atproto/sync/listRepos'
export * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOfUpdate'
export * as ComAtprotoSyncRequestCrawl from './types/com/atproto/sync/requestCrawl'
export * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscribeRepos'
export * as ComAtprotoTempUpgradeRepoVersion from './types/com/atproto/temp/upgradeRepoVersion'
export * as AppBskyActorDefs from './types/app/bsky/actor/defs'
export * as AppBskyActorGetPreferences from './types/app/bsky/actor/getPreferences'
export * as AppBskyActorGetProfile from './types/app/bsky/actor/getProfile'
Expand Down Expand Up @@ -335,7 +333,6 @@ export class AtprotoNS {
repo: RepoNS
server: ServerNS
sync: SyncNS
temp: TempNS

constructor(service: AtpServiceClient) {
this._service = service
Expand All @@ -346,7 +343,6 @@ export class AtprotoNS {
this.repo = new RepoNS(service)
this.server = new ServerNS(service)
this.sync = new SyncNS(service)
this.temp = new TempNS(service)
}
}

Expand Down Expand Up @@ -1022,25 +1018,6 @@ export class SyncNS {
}
}

export class TempNS {
_service: AtpServiceClient

constructor(service: AtpServiceClient) {
this._service = service
}

upgradeRepoVersion(
data?: ComAtprotoTempUpgradeRepoVersion.InputSchema,
opts?: ComAtprotoTempUpgradeRepoVersion.CallOptions,
): Promise<ComAtprotoTempUpgradeRepoVersion.Response> {
return this._service.xrpc
.call('com.atproto.temp.upgradeRepoVersion', opts?.qp, data, opts)
.catch((e) => {
throw ComAtprotoTempUpgradeRepoVersion.toKnownErr(e)
})
}
}

export class AppNS {
_service: AtpServiceClient
bsky: BskyNS
Expand Down
27 changes: 0 additions & 27 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3521,32 +3521,6 @@ export const schemaDict = {
},
},
},
ComAtprotoTempUpgradeRepoVersion: {
lexicon: 1,
id: 'com.atproto.temp.upgradeRepoVersion',
defs: {
main: {
type: 'procedure',
description: 'Upgrade a repo to v3',
input: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['did'],
properties: {
did: {
type: 'string',
format: 'did',
},
force: {
type: 'boolean',
},
},
},
},
},
},
},
AppBskyActorDefs: {
lexicon: 1,
id: 'app.bsky.actor.defs',
Expand Down Expand Up @@ -7298,7 +7272,6 @@ export const ids = {
ComAtprotoSyncNotifyOfUpdate: 'com.atproto.sync.notifyOfUpdate',
ComAtprotoSyncRequestCrawl: 'com.atproto.sync.requestCrawl',
ComAtprotoSyncSubscribeRepos: 'com.atproto.sync.subscribeRepos',
ComAtprotoTempUpgradeRepoVersion: 'com.atproto.temp.upgradeRepoVersion',
AppBskyActorDefs: 'app.bsky.actor.defs',
AppBskyActorGetPreferences: 'app.bsky.actor.getPreferences',
AppBskyActorGetProfile: 'app.bsky.actor.getProfile',
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion packages/api/src/rich-text/detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function detectFacets(text: UnicodeString): Facet[] | undefined {
features: [
{
$type: 'app.bsky.richtext.facet#tag',
tag,
tag: tag.replace(/^#/, ''),
},
],
})
Expand Down
34 changes: 17 additions & 17 deletions packages/api/tests/rich-text-detection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,28 +216,28 @@ describe('detectFacets', () => {
string[],
{ byteStart: number; byteEnd: number }[],
][] = [
['#a', ['#a'], [{ byteStart: 0, byteEnd: 2 }]],
['#a', ['a'], [{ byteStart: 0, byteEnd: 2 }]],
[
'#a #b',
['#a', '#b'],
['a', 'b'],
[
{ byteStart: 0, byteEnd: 2 },
{ byteStart: 3, byteEnd: 5 },
],
],
['#1', [], []],
['#tag', ['#tag'], [{ byteStart: 0, byteEnd: 4 }]],
['body #tag', ['#tag'], [{ byteStart: 5, byteEnd: 9 }]],
['#tag body', ['#tag'], [{ byteStart: 0, byteEnd: 4 }]],
['body #tag body', ['#tag'], [{ byteStart: 5, byteEnd: 9 }]],
['#tag', ['tag'], [{ byteStart: 0, byteEnd: 4 }]],
['body #tag', ['tag'], [{ byteStart: 5, byteEnd: 9 }]],
['#tag body', ['tag'], [{ byteStart: 0, byteEnd: 4 }]],
['body #tag body', ['tag'], [{ byteStart: 5, byteEnd: 9 }]],
['body #1', [], []],
['body #a1', ['#a1'], [{ byteStart: 5, byteEnd: 8 }]],
['body #a1', ['a1'], [{ byteStart: 5, byteEnd: 8 }]],
['#', [], []],
['text #', [], []],
['text # text', [], []],
[
'body #thisisa64characterstring_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
['#thisisa64characterstring_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'],
['thisisa64characterstring_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'],
[{ byteStart: 5, byteEnd: 71 }],
],
[
Expand All @@ -247,19 +247,19 @@ describe('detectFacets', () => {
],
[
'its a #double#rainbow',
['#double#rainbow'],
['double#rainbow'],
[{ byteStart: 6, byteEnd: 21 }],
],
['##hashash', ['##hashash'], [{ byteStart: 0, byteEnd: 9 }]],
['some #n0n3s@n5e!', ['#n0n3s@n5e'], [{ byteStart: 5, byteEnd: 15 }]],
['##hashash', ['#hashash'], [{ byteStart: 0, byteEnd: 9 }]],
['some #n0n3s@n5e!', ['n0n3s@n5e'], [{ byteStart: 5, byteEnd: 15 }]],
[
'works #with,punctuation',
['#with,punctuation'],
['with,punctuation'],
[{ byteStart: 6, byteEnd: 23 }],
],
[
'strips trailing #punctuation, #like. #this!',
['#punctuation', '#like', '#this'],
['punctuation', 'like', 'this'],
[
{ byteStart: 16, byteEnd: 28 },
{ byteStart: 30, byteEnd: 35 },
Expand All @@ -268,20 +268,20 @@ describe('detectFacets', () => {
],
[
'strips #multi_trailing___...',
['#multi_trailing'],
['multi_trailing'],
[{ byteStart: 7, byteEnd: 22 }],
],
[
'works with #🦋 emoji, and #butter🦋fly',
['#🦋', '#butter🦋fly'],
['🦋', 'butter🦋fly'],
[
{ byteStart: 11, byteEnd: 16 },
{ byteStart: 28, byteEnd: 42 },
],
],
[
'#same #same #but #diff',
['#same', '#same', '#but', '#diff'],
['same', 'same', 'but', 'diff'],
[
{ byteStart: 0, byteEnd: 5 },
{ byteStart: 6, byteEnd: 11 },
Expand All @@ -298,7 +298,7 @@ describe('detectFacets', () => {
let detectedTags: string[] = []

Check warning on line 298 in packages/api/tests/rich-text-detection.test.ts

View workflow job for this annotation

GitHub Actions / Verify

'detectedTags' is never reassigned. Use 'const' instead
let detectedIndices: { byteStart: number; byteEnd: number }[] = []

Check warning on line 299 in packages/api/tests/rich-text-detection.test.ts

View workflow job for this annotation

GitHub Actions / Verify

'detectedIndices' is never reassigned. Use 'const' instead

for (const { facet } of rt.segments()) {
for (const { facet, ...rest } of rt.segments()) {

Check warning on line 301 in packages/api/tests/rich-text-detection.test.ts

View workflow job for this annotation

GitHub Actions / Verify

'rest' is assigned a value but never used. Allowed unused vars must match /^_/u
if (!facet) continue
for (const feature of facet.features) {
if (isTag(feature)) {
Expand Down
11 changes: 11 additions & 0 deletions packages/bsky/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @atproto/bsky

# <<<<<<< HEAD

## 0.0.10

### Patch Changes

- Updated dependencies [[`35b616cd`](https://github.com/bluesky-social/atproto/commit/35b616cd82232879937afc88d3f77d20c6395276)]:
- @atproto/api@0.6.19

> > > > > > > main
## 0.0.9

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/bsky/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@atproto/bsky",
"version": "0.0.9",
"version": "0.0.10",
"license": "MIT",
"description": "Reference implementation of app.bsky App View (Bluesky API)",
"keywords": [
Expand Down
58 changes: 36 additions & 22 deletions packages/bsky/src/api/app/bsky/actor/searchActors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { sql } from 'kysely'
import AppContext from '../../../../context'
import { Server } from '../../../../lexicon'
import {
cleanTerm,
cleanQuery,
getUserSearchQuery,
SearchKeyset,
} from '../../../../services/util/search'
Expand All @@ -11,37 +11,51 @@ export default function (server: Server, ctx: AppContext) {
server.app.bsky.actor.searchActors({
auth: ctx.authOptionalVerifier,
handler: async ({ auth, params }) => {
let { cursor, limit, term: rawTerm, q: rawQ } = params
const { cursor, limit } = params
const requester = auth.credentials.did

// prefer new 'q' query param over deprecated 'term'
if (rawQ) {
rawTerm = rawQ
}

const term = cleanTerm(rawTerm || '')

const rawQuery = params.q ?? params.term
const query = cleanQuery(rawQuery || '')
const db = ctx.db.getReplica('search')

const results = term
? await getUserSearchQuery(db, { term, limit, cursor })
.select('distance')
.selectAll('actor')
.execute()
: []
const keyset = new SearchKeyset(sql``, sql``)
let results: string[]
let resCursor: string | undefined
if (ctx.searchAgent) {
const res =
await ctx.searchAgent.api.app.bsky.unspecced.searchActorsSkeleton({
q: query,
cursor,
limit,
})
results = res.data.actors.map((a) => a.did)
resCursor = res.data.cursor
} else {
const res = query
? await getUserSearchQuery(db, { query, limit, cursor })
.select('distance')
.selectAll('actor')
.execute()
: []
results = res.map((a) => a.did)
const keyset = new SearchKeyset(sql``, sql``)
resCursor = keyset.packFromResult(res)
}

const actors = await ctx.services
.actor(db)
.views.profilesList(results, requester)
const filtered = actors.filter(
(actor) => !actor.viewer?.blocking && !actor.viewer?.blockedBy,
)
.views.profiles(results, requester)

const SKIP = []
const filtered = results.flatMap((did) => {
const actor = actors[did]
if (!actor) return SKIP
if (actor.viewer?.blocking || actor.viewer?.blockedBy) return SKIP
return actor
})

return {
encoding: 'application/json',
body: {
cursor: keyset.packFromResult(results),
cursor: resCursor,
actors: filtered,
},
}
Expand Down
Loading

0 comments on commit a903798

Please sign in to comment.