Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into social-proof-blocks
Browse files Browse the repository at this point in the history
* origin/main:
  Appview: simple fix for no-hosted known followers (#2609)
  bsky: syntax typo in README (#2601)
  Use detailed profile view for `getSuggestions` (#2596)
  • Loading branch information
estrattonbailey committed Jun 26, 2024
2 parents 0f5fa1a + 4619ef8 commit 999792c
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/bsky/src/api/app/bsky/actor/getSuggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const presentation = (input: {
}) => {
const { ctx, skeleton, hydration } = input
const actors = mapDefined(skeleton.dids, (did) =>
ctx.views.profile(did, hydration),
ctx.views.profileKnownFollowers(did, hydration),
)
return {
actors,
Expand Down
27 changes: 27 additions & 0 deletions packages/bsky/src/views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,29 @@ export class Views {
}
}

profileKnownFollowers(
did: string,
state: HydrationState,
): ProfileView | undefined {
const actor = state.actors?.get(did)
if (!actor) return
const baseView = this.profile(did, state)
if (!baseView) return
const knownFollowersSkeleton = state.knownFollowers?.get(did)
const knownFollowers = knownFollowersSkeleton
? this.knownFollowers(knownFollowersSkeleton, state, did)
: undefined
return {
...baseView,
viewer: baseView.viewer
? {
...baseView.viewer,
knownFollowers,
}
: undefined,
}
}

profileViewer(
did: string,
state: HydrationState,
Expand Down Expand Up @@ -250,6 +273,10 @@ export class Views {
if (blocks && blocks.get(did) === true) {
return undefined
}
if (this.actorIsNoHosted(did, state)) {
// @TODO only needed right now to work around getProfile's { includeTakedowns: true }
return undefined
}
return this.profileBasic(did, state)
})
return { count: knownFollowers.count, followers }
Expand Down
72 changes: 70 additions & 2 deletions packages/pds/tests/proxied/__snapshots__/views.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,90 @@ Object {
"viewer": Object {
"blockedBy": false,
"followedBy": "record(0)",
"knownFollowers": Object {
"count": 1,
"followers": Array [
Object {
"avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg",
"createdAt": "1970-01-01T00:00:00.000Z",
"did": "user(2)",
"displayName": "ali",
"handle": "alice.test",
"labels": Array [
Object {
"cid": "cids(1)",
"cts": "1970-01-01T00:00:00.000Z",
"src": "user(2)",
"uri": "record(3)",
"val": "self-label-a",
},
Object {
"cid": "cids(1)",
"cts": "1970-01-01T00:00:00.000Z",
"src": "user(2)",
"uri": "record(3)",
"val": "self-label-b",
},
],
"viewer": Object {
"blockedBy": false,
"followedBy": "record(2)",
"following": "record(1)",
"muted": false,
},
},
],
},
"muted": false,
},
},
Object {
"did": "user(2)",
"did": "user(4)",
"handle": "dan.test",
"labels": Array [
Object {
"cts": "1970-01-01T00:00:00.000Z",
"src": "did:example:labeler",
"uri": "user(2)",
"uri": "user(4)",
"val": "repo-action-label",
},
],
"viewer": Object {
"blockedBy": false,
"knownFollowers": Object {
"count": 1,
"followers": Array [
Object {
"avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(0)@jpeg",
"createdAt": "1970-01-01T00:00:00.000Z",
"did": "user(2)",
"displayName": "ali",
"handle": "alice.test",
"labels": Array [
Object {
"cid": "cids(1)",
"cts": "1970-01-01T00:00:00.000Z",
"src": "user(2)",
"uri": "record(3)",
"val": "self-label-a",
},
Object {
"cid": "cids(1)",
"cts": "1970-01-01T00:00:00.000Z",
"src": "user(2)",
"uri": "record(3)",
"val": "self-label-b",
},
],
"viewer": Object {
"blockedBy": false,
"followedBy": "record(2)",
"following": "record(1)",
"muted": false,
},
},
],
},
"muted": false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion services/bsky/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This is the service entrypoint for the bsky appview. The entrypoint command shou
- `BSKY_PUBLIC_URL` - (required) the public url of the appview, e.g. `https://api.bsky.app`.
- `BSKY_DID_PLC_URL` - (required) the url of the PLC service used for looking up did documents, e.g. `https://plc.directory`.
- `BSKY_DATAPLANE_URL` - (required) the url where the backing dataplane service lives.
- `BSKY_SERVICE_SIGNING_KEY` - (required) the public signing key in the form of a `did:key`, used for service-to-service auth. Advertised in the appview's `did:web`` document.
- `BSKY_SERVICE_SIGNING_KEY` - (required) the public signing key in the form of a `did:key`, used for service-to-service auth. Advertised in the appview's `did:web` document.
- `BSKY_ADMIN_PASSWORDS` - (alt. `BSKY_ADMIN_PASSWORD`) (required) comma-separated list of admin passwords used for role-based auth.
- `NODE_ENV` - (recommended) for production usage, should be set to `production`. Otherwise all responses are validated on their way out. There may be other effects of not setting this to `production`, as dependencies may also implement debug modes based on its value.
- `BSKY_VERSION` - (recommended) version of the bsky service. This is advertised by the health endpoint.
Expand Down

0 comments on commit 999792c

Please sign in to comment.