Skip to content

Commit

Permalink
Add isFallback to getSuggestedFollowsByActor method (#2805)
Browse files Browse the repository at this point in the history
* Add isFallback to `getSuggestedFollowsByActor`

Inferred based on returned `relativeToDid` from the suggestions
response.

* Integrate new params

* Fix logic
  • Loading branch information
estrattonbailey authored Sep 13, 2024
1 parent a06634a commit 319aa7c
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lexicons/app/bsky/graph/getSuggestedFollowsByActor.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
"type": "ref",
"ref": "app.bsky.actor.defs#profileView"
}
},
"isFallback": {
"type": "boolean",
"description": "If true, response has fallen-back to generic results, and is not scoped using relativeToDid",
"default": false
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions lexicons/app/bsky/unspecced/getSuggestionsSkeleton.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
"type": "ref",
"ref": "app.bsky.unspecced.defs#skeletonSearchActor"
}
},
"relativeToDid": {
"type": "string",
"format": "did",
"description": "DID of the account these suggestions are relative to. If this is returned undefined, suggestions are based on the viewer."
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8236,6 +8236,12 @@ export const schemaDict = {
ref: 'lex:app.bsky.actor.defs#profileView',
},
},
isFallback: {
type: 'boolean',
description:
'If true, response has fallen-back to generic results, and is not scoped using relativeToDid',
default: false,
},
},
},
},
Expand Down Expand Up @@ -9192,6 +9198,12 @@ export const schemaDict = {
ref: 'lex:app.bsky.unspecced.defs#skeletonSearchActor',
},
},
relativeToDid: {
type: 'string',
format: 'did',
description:
'DID of the account these suggestions are relative to. If this is returned undefined, suggestions are based on the viewer.',
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export type InputSchema = undefined

export interface OutputSchema {
suggestions: AppBskyActorDefs.ProfileView[]
/** If true, response has fallen-back to generic results, and is not scoped using relativeToDid */
isFallback: boolean
[k: string]: unknown
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export type InputSchema = undefined
export interface OutputSchema {
cursor?: string
actors: AppBskyUnspeccedDefs.SkeletonSearchActor[]
/** DID of the account these suggestions are relative to. If this is returned undefined, suggestions are based on the viewer. */
relativeToDid?: string
[k: string]: unknown
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const skeleton = async (input: SkeletonFnInput<Context, Params>) => {
{ headers: params.headers },
)
return {
isFallback: !res.data.relativeToDid,
suggestedDids: res.data.actors.map((a) => a.did),
headers: res.headers,
}
Expand All @@ -80,6 +81,7 @@ const skeleton = async (input: SkeletonFnInput<Context, Params>) => {
relativeToDid,
})
return {
isFallback: true,
suggestedDids: dids,
}
}
Expand Down Expand Up @@ -113,7 +115,7 @@ const presentation = (
const suggestions = mapDefined(suggestedDids, (did) =>
ctx.views.profileDetailed(did, hydration),
)
return { suggestions, headers }
return { isFallback: skeleton.isFallback, suggestions, headers }
}

type Context = {
Expand All @@ -129,6 +131,7 @@ type Params = QueryParams & {
}

type SkeletonState = {
isFallback: boolean
suggestedDids: string[]
headers?: Record<string, string>
}
12 changes: 12 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8236,6 +8236,12 @@ export const schemaDict = {
ref: 'lex:app.bsky.actor.defs#profileView',
},
},
isFallback: {
type: 'boolean',
description:
'If true, response has fallen-back to generic results, and is not scoped using relativeToDid',
default: false,
},
},
},
},
Expand Down Expand Up @@ -9192,6 +9198,12 @@ export const schemaDict = {
ref: 'lex:app.bsky.unspecced.defs#skeletonSearchActor',
},
},
relativeToDid: {
type: 'string',
format: 'did',
description:
'DID of the account these suggestions are relative to. If this is returned undefined, suggestions are based on the viewer.',
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export type InputSchema = undefined

export interface OutputSchema {
suggestions: AppBskyActorDefs.ProfileView[]
/** If true, response has fallen-back to generic results, and is not scoped using relativeToDid */
isFallback?: boolean
[k: string]: unknown
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export type InputSchema = undefined
export interface OutputSchema {
cursor?: string
actors: AppBskyUnspeccedDefs.SkeletonSearchActor[]
/** DID of the account these suggestions are relative to. If this is returned undefined, suggestions are based on the viewer. */
relativeToDid?: string
[k: string]: unknown
}

Expand Down
12 changes: 12 additions & 0 deletions packages/ozone/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8236,6 +8236,12 @@ export const schemaDict = {
ref: 'lex:app.bsky.actor.defs#profileView',
},
},
isFallback: {
type: 'boolean',
description:
'If true, response has fallen-back to generic results, and is not scoped using relativeToDid',
default: false,
},
},
},
},
Expand Down Expand Up @@ -9192,6 +9198,12 @@ export const schemaDict = {
ref: 'lex:app.bsky.unspecced.defs#skeletonSearchActor',
},
},
relativeToDid: {
type: 'string',
format: 'did',
description:
'DID of the account these suggestions are relative to. If this is returned undefined, suggestions are based on the viewer.',
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export type InputSchema = undefined

export interface OutputSchema {
suggestions: AppBskyActorDefs.ProfileView[]
/** If true, response has fallen-back to generic results, and is not scoped using relativeToDid */
isFallback?: boolean
[k: string]: unknown
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export type InputSchema = undefined
export interface OutputSchema {
cursor?: string
actors: AppBskyUnspeccedDefs.SkeletonSearchActor[]
/** DID of the account these suggestions are relative to. If this is returned undefined, suggestions are based on the viewer. */
relativeToDid?: string
[k: string]: unknown
}

Expand Down
12 changes: 12 additions & 0 deletions packages/pds/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8236,6 +8236,12 @@ export const schemaDict = {
ref: 'lex:app.bsky.actor.defs#profileView',
},
},
isFallback: {
type: 'boolean',
description:
'If true, response has fallen-back to generic results, and is not scoped using relativeToDid',
default: false,
},
},
},
},
Expand Down Expand Up @@ -9192,6 +9198,12 @@ export const schemaDict = {
ref: 'lex:app.bsky.unspecced.defs#skeletonSearchActor',
},
},
relativeToDid: {
type: 'string',
format: 'did',
description:
'DID of the account these suggestions are relative to. If this is returned undefined, suggestions are based on the viewer.',
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export type InputSchema = undefined

export interface OutputSchema {
suggestions: AppBskyActorDefs.ProfileView[]
/** If true, response has fallen-back to generic results, and is not scoped using relativeToDid */
isFallback?: boolean
[k: string]: unknown
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export type InputSchema = undefined
export interface OutputSchema {
cursor?: string
actors: AppBskyUnspeccedDefs.SkeletonSearchActor[]
/** DID of the account these suggestions are relative to. If this is returned undefined, suggestions are based on the viewer. */
relativeToDid?: string
[k: string]: unknown
}

Expand Down

0 comments on commit 319aa7c

Please sign in to comment.