Skip to content

Commit

Permalink
Appview: add associated.labeler info to all profile views (bluesky-so…
Browse files Browse the repository at this point in the history
…cial#2341)

* lexicon: add associated field to profile and profile-basic views, for indicating whether labeler

* appview: add associated.labeler to profile and profile-basic views

* dev-env: downgrade get-port, non-esm-only version
  • Loading branch information
devinivy authored Mar 19, 2024
1 parent ae4d0f9 commit c28e374
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 3 deletions.
8 changes: 8 additions & 0 deletions lexicons/app/bsky/actor/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"maxLength": 640
},
"avatar": { "type": "string" },
"associated": {
"type": "ref",
"ref": "#profileAssociated"
},
"viewer": { "type": "ref", "ref": "#viewerState" },
"labels": {
"type": "array",
Expand All @@ -38,6 +42,10 @@
"maxLength": 2560
},
"avatar": { "type": "string" },
"associated": {
"type": "ref",
"ref": "#profileAssociated"
},
"indexedAt": { "type": "string", "format": "datetime" },
"viewer": { "type": "ref", "ref": "#viewerState" },
"labels": {
Expand Down
8 changes: 8 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3622,6 +3622,10 @@ export const schemaDict = {
avatar: {
type: 'string',
},
associated: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#profileAssociated',
},
viewer: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#viewerState',
Expand Down Expand Up @@ -3660,6 +3664,10 @@ export const schemaDict = {
avatar: {
type: 'string',
},
associated: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#profileAssociated',
},
indexedAt: {
type: 'string',
format: 'datetime',
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/client/types/app/bsky/actor/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface ProfileViewBasic {
handle: string
displayName?: string
avatar?: string
associated?: ProfileAssociated
viewer?: ViewerState
labels?: ComAtprotoLabelDefs.Label[]
[k: string]: unknown
Expand All @@ -36,6 +37,7 @@ export interface ProfileView {
displayName?: string
description?: string
avatar?: string
associated?: ProfileAssociated
indexedAt?: string
viewer?: ViewerState
labels?: ComAtprotoLabelDefs.Label[]
Expand Down
8 changes: 8 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3622,6 +3622,10 @@ export const schemaDict = {
avatar: {
type: 'string',
},
associated: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#profileAssociated',
},
viewer: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#viewerState',
Expand Down Expand Up @@ -3660,6 +3664,10 @@ export const schemaDict = {
avatar: {
type: 'string',
},
associated: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#profileAssociated',
},
indexedAt: {
type: 'string',
format: 'datetime',
Expand Down
2 changes: 2 additions & 0 deletions packages/bsky/src/lexicon/types/app/bsky/actor/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface ProfileViewBasic {
handle: string
displayName?: string
avatar?: string
associated?: ProfileAssociated
viewer?: ViewerState
labels?: ComAtprotoLabelDefs.Label[]
[k: string]: unknown
Expand All @@ -36,6 +37,7 @@ export interface ProfileView {
displayName?: string
description?: string
avatar?: string
associated?: ProfileAssociated
indexedAt?: string
viewer?: ViewerState
labels?: ComAtprotoLabelDefs.Label[]
Expand Down
3 changes: 3 additions & 0 deletions packages/bsky/src/views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ export class Views {
cidFromBlobJson(actor.profile.avatar),
)
: undefined,
// associated.feedgens and associated.lists info not necessarily included
// on profile and profile-basic views, but should be on profile-detailed.
associated: actor?.isLabeler ? { labeler: true } : undefined,
viewer: this.profileViewer(did, state),
labels,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Object {
"$type": "app.bsky.labeler.defs#labelerView",
"cid": "cids(0)",
"creator": Object {
"associated": Object {
"labeler": true,
},
"avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg",
"description": "its me!",
"did": "user(0)",
Expand Down Expand Up @@ -48,6 +51,9 @@ Object {
"$type": "app.bsky.labeler.defs#labelerView",
"cid": "cids(3)",
"creator": Object {
"associated": Object {
"labeler": true,
},
"avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg",
"description": "hi im bob label_me",
"did": "user(2)",
Expand Down Expand Up @@ -77,6 +83,9 @@ Object {
"$type": "app.bsky.labeler.defs#labelerViewDetailed",
"cid": "cids(0)",
"creator": Object {
"associated": Object {
"labeler": true,
},
"avatar": "https://bsky.public.url/img/avatar/plain/user(1)/cids(1)@jpeg",
"description": "its me!",
"did": "user(0)",
Expand Down Expand Up @@ -126,6 +135,9 @@ Object {
"$type": "app.bsky.labeler.defs#labelerViewDetailed",
"cid": "cids(3)",
"creator": Object {
"associated": Object {
"labeler": true,
},
"avatar": "https://bsky.public.url/img/avatar/plain/user(3)/cids(1)@jpeg",
"description": "hi im bob label_me",
"did": "user(2)",
Expand Down
9 changes: 9 additions & 0 deletions packages/bsky/tests/views/labeler-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ describe('labeler service views', () => {
)
})

it('renders profile as labeler in non-detailed profile views', async () => {
const { data: res } = await agent.api.app.bsky.actor.searchActors(
{ q: sc.accounts[alice].handle },
{ headers: await network.serviceHeaders(bob) },
)
expect(res.actors.length).toBe(1)
expect(res.actors[0].associated?.labeler).toBe(true)
})

it('blocked by labeler takedown', async () => {
await network.bsky.ctx.dataplane.takedownActor({ did: alice })
const res = await agent.api.app.bsky.labeler.getServices(
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"axios": "^0.27.2",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"get-port": "^6.1.2",
"get-port": "^5.1.1",
"multiformats": "^9.9.0",
"uint8arrays": "3.0.0"
}
Expand Down
8 changes: 8 additions & 0 deletions packages/ozone/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3622,6 +3622,10 @@ export const schemaDict = {
avatar: {
type: 'string',
},
associated: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#profileAssociated',
},
viewer: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#viewerState',
Expand Down Expand Up @@ -3660,6 +3664,10 @@ export const schemaDict = {
avatar: {
type: 'string',
},
associated: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#profileAssociated',
},
indexedAt: {
type: 'string',
format: 'datetime',
Expand Down
2 changes: 2 additions & 0 deletions packages/ozone/src/lexicon/types/app/bsky/actor/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface ProfileViewBasic {
handle: string
displayName?: string
avatar?: string
associated?: ProfileAssociated
viewer?: ViewerState
labels?: ComAtprotoLabelDefs.Label[]
[k: string]: unknown
Expand All @@ -36,6 +37,7 @@ export interface ProfileView {
displayName?: string
description?: string
avatar?: string
associated?: ProfileAssociated
indexedAt?: string
viewer?: ViewerState
labels?: ComAtprotoLabelDefs.Label[]
Expand Down
8 changes: 8 additions & 0 deletions packages/pds/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3622,6 +3622,10 @@ export const schemaDict = {
avatar: {
type: 'string',
},
associated: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#profileAssociated',
},
viewer: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#viewerState',
Expand Down Expand Up @@ -3660,6 +3664,10 @@ export const schemaDict = {
avatar: {
type: 'string',
},
associated: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#profileAssociated',
},
indexedAt: {
type: 'string',
format: 'datetime',
Expand Down
2 changes: 2 additions & 0 deletions packages/pds/src/lexicon/types/app/bsky/actor/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface ProfileViewBasic {
handle: string
displayName?: string
avatar?: string
associated?: ProfileAssociated
viewer?: ViewerState
labels?: ComAtprotoLabelDefs.Label[]
[k: string]: unknown
Expand All @@ -36,6 +37,7 @@ export interface ProfileView {
displayName?: string
description?: string
avatar?: string
associated?: ProfileAssociated
indexedAt?: string
viewer?: ViewerState
labels?: ComAtprotoLabelDefs.Label[]
Expand Down
10 changes: 8 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c28e374

Please sign in to comment.