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

Add isFallback to getSuggestedFollowsByActor method #2805

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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": {
estrattonbailey marked this conversation as resolved.
Show resolved Hide resolved
"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 @@ -8199,6 +8199,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 @@ -9155,6 +9161,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 @@ -8199,6 +8199,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 @@ -9155,6 +9161,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 @@ -8199,6 +8199,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 @@ -9155,6 +9161,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 @@ -8199,6 +8199,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 @@ -9155,6 +9161,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