Skip to content

Commit

Permalink
Social proof (#2557)
Browse files Browse the repository at this point in the history
* lexicon: initial social proof lexicons

* Social proof (#2548)

* Update deactivation through updateSubjectStatus (#2539)

* attach hosting status to entryway session responses

* integrate account deactivation in with entryway

* tidy

* tidy

* chnageset

* update changeset

* Version packages (#2546)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* lexicon: initial social proof lexicons

* feat: add generated types for social proof

* feat: social proof implementation

---------

Co-authored-by: Daniel Holmgren <dtholmgren@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Devin Ivy <devinivy@gmail.com>

* Rename

* Codegen

* Implementation, renaming

* Remove only

* Add depth resolution param, update snaps

* Be smart like Devin

* Snaps

* Revert lock changes

* Snaps

* Snaps

* Snaps

* Add changeset

* Snaps

* Revert lock changes

* Add test for basic profile

* Add getKnownFollowersEndpoint

* Make it zero

* Return max of 5

* Remove isNoHosted

* Use array and index

* Clarify ternary

* Remove includeKnownFollowers from views

* Revert "Return max of 5"

This reverts commit 1a27eb7.

* Ope missed a param

* Rename view method

* Don't return viewer if undefined

* Format

* Clean up hydrator

* Snaps

* Update proto, use batch endpoint

* Format

* Fix proto, codegen

* Remove unneeded promise

* Move hydrator into route handler

* Add hydrationLogger

* Handle failures of dataplane getKnownFollowers

* Use .at(), defer to params.limit

* Create instance of FollowsFollowing for better type support

* Support knownFollowers in mergeStates

* Add back fat-fingered deleted imports

* Filter out blocks

* Codegen lex

* Naive block filtering

* Remove whitespace edits

* Update changeset desc

* Remove whitespace

---------

Co-authored-by: Devin Ivy <devinivy@gmail.com>
Co-authored-by: dirkmc <dirkmdev@gmail.com>
Co-authored-by: Daniel Holmgren <dtholmgren@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
6 people authored Jun 11, 2024
1 parent 71e3edc commit 58abcbd
Show file tree
Hide file tree
Showing 33 changed files with 1,427 additions and 56 deletions.
7 changes: 7 additions & 0 deletions .changeset/rare-books-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@atproto/api": patch
---

Adds "social proof": `knowFollowers` to `ViewerState` for `ProfileViewDetailed`
views and `app.bsky.graph.getKnownFollowers` method for listing known followers
of a given user.
23 changes: 22 additions & 1 deletion lexicons/app/bsky/actor/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,28 @@
"ref": "app.bsky.graph.defs#listViewBasic"
},
"following": { "type": "string", "format": "at-uri" },
"followedBy": { "type": "string", "format": "at-uri" }
"followedBy": { "type": "string", "format": "at-uri" },
"knownFollowers": {
"type": "ref",
"ref": "#knownFollowers"
}
}
},
"knownFollowers": {
"type": "object",
"description": "The subject's followers whom you also follow",
"required": ["count", "followers"],
"properties": {
"count": { "type": "integer" },
"followers": {
"type": "array",
"minLength": 0,
"maxLength": 5,
"items": {
"type": "ref",
"ref": "#profileViewBasic"
}
}
}
},
"preferences": {
Expand Down
45 changes: 45 additions & 0 deletions lexicons/app/bsky/graph/getKnownFollowers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"lexicon": 1,
"id": "app.bsky.graph.getKnownFollowers",
"defs": {
"main": {
"type": "query",
"description": "Enumerates accounts which follow a specified account (actor) and are followed by the viewer.",
"parameters": {
"type": "params",
"required": ["actor"],
"properties": {
"actor": { "type": "string", "format": "at-identifier" },
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 50
},
"cursor": { "type": "string" }
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["subject", "followers"],
"properties": {
"subject": {
"type": "ref",
"ref": "app.bsky.actor.defs#profileView"
},
"cursor": { "type": "string" },
"followers": {
"type": "array",
"items": {
"type": "ref",
"ref": "app.bsky.actor.defs#profileView"
}
}
}
}
}
}
}
}
13 changes: 13 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ import * as AppBskyGraphFollow from './types/app/bsky/graph/follow'
import * as AppBskyGraphGetBlocks from './types/app/bsky/graph/getBlocks'
import * as AppBskyGraphGetFollowers from './types/app/bsky/graph/getFollowers'
import * as AppBskyGraphGetFollows from './types/app/bsky/graph/getFollows'
import * as AppBskyGraphGetKnownFollowers from './types/app/bsky/graph/getKnownFollowers'
import * as AppBskyGraphGetList from './types/app/bsky/graph/getList'
import * as AppBskyGraphGetListBlocks from './types/app/bsky/graph/getListBlocks'
import * as AppBskyGraphGetListMutes from './types/app/bsky/graph/getListMutes'
Expand Down Expand Up @@ -312,6 +313,7 @@ export * as AppBskyGraphFollow from './types/app/bsky/graph/follow'
export * as AppBskyGraphGetBlocks from './types/app/bsky/graph/getBlocks'
export * as AppBskyGraphGetFollowers from './types/app/bsky/graph/getFollowers'
export * as AppBskyGraphGetFollows from './types/app/bsky/graph/getFollows'
export * as AppBskyGraphGetKnownFollowers from './types/app/bsky/graph/getKnownFollowers'
export * as AppBskyGraphGetList from './types/app/bsky/graph/getList'
export * as AppBskyGraphGetListBlocks from './types/app/bsky/graph/getListBlocks'
export * as AppBskyGraphGetListMutes from './types/app/bsky/graph/getListMutes'
Expand Down Expand Up @@ -2097,6 +2099,17 @@ export class AppBskyGraphNS {
})
}

getKnownFollowers(
params?: AppBskyGraphGetKnownFollowers.QueryParams,
opts?: AppBskyGraphGetKnownFollowers.CallOptions,
): Promise<AppBskyGraphGetKnownFollowers.Response> {
return this._service.xrpc
.call('app.bsky.graph.getKnownFollowers', params, undefined, opts)
.catch((e) => {
throw AppBskyGraphGetKnownFollowers.toKnownErr(e)
})
}

getList(
params?: AppBskyGraphGetList.QueryParams,
opts?: AppBskyGraphGetList.CallOptions,
Expand Down
77 changes: 77 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4107,6 +4107,29 @@ export const schemaDict = {
type: 'string',
format: 'at-uri',
},
knownFollowers: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#knownFollowers',
},
},
},
knownFollowers: {
type: 'object',
description: "The subject's followers whom you also follow",
required: ['count', 'followers'],
properties: {
count: {
type: 'integer',
},
followers: {
type: 'array',
minLength: 0,
maxLength: 5,
items: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#profileViewBasic',
},
},
},
},
preferences: {
Expand Down Expand Up @@ -7101,6 +7124,59 @@ export const schemaDict = {
},
},
},
AppBskyGraphGetKnownFollowers: {
lexicon: 1,
id: 'app.bsky.graph.getKnownFollowers',
defs: {
main: {
type: 'query',
description:
'Enumerates accounts which follow a specified account (actor) and are followed by the viewer.',
parameters: {
type: 'params',
required: ['actor'],
properties: {
actor: {
type: 'string',
format: 'at-identifier',
},
limit: {
type: 'integer',
minimum: 1,
maximum: 100,
default: 50,
},
cursor: {
type: 'string',
},
},
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['subject', 'followers'],
properties: {
subject: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#profileView',
},
cursor: {
type: 'string',
},
followers: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#profileView',
},
},
},
},
},
},
},
},
AppBskyGraphGetList: {
lexicon: 1,
id: 'app.bsky.graph.getList',
Expand Down Expand Up @@ -11015,6 +11091,7 @@ export const ids = {
AppBskyGraphGetBlocks: 'app.bsky.graph.getBlocks',
AppBskyGraphGetFollowers: 'app.bsky.graph.getFollowers',
AppBskyGraphGetFollows: 'app.bsky.graph.getFollows',
AppBskyGraphGetKnownFollowers: 'app.bsky.graph.getKnownFollowers',
AppBskyGraphGetList: 'app.bsky.graph.getList',
AppBskyGraphGetListBlocks: 'app.bsky.graph.getListBlocks',
AppBskyGraphGetListMutes: 'app.bsky.graph.getListMutes',
Expand Down
20 changes: 20 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 @@ -133,6 +133,7 @@ export interface ViewerState {
blockingByList?: AppBskyGraphDefs.ListViewBasic
following?: string
followedBy?: string
knownFollowers?: KnownFollowers
[k: string]: unknown
}

Expand All @@ -148,6 +149,25 @@ export function validateViewerState(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.actor.defs#viewerState', v)
}

/** The subject's followers whom you also follow */
export interface KnownFollowers {
count: number
followers: ProfileViewBasic[]
[k: string]: unknown
}

export function isKnownFollowers(v: unknown): v is KnownFollowers {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'app.bsky.actor.defs#knownFollowers'
)
}

export function validateKnownFollowers(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.actor.defs#knownFollowers', v)
}

export type Preferences = (
| AdultContentPref
| ContentLabelPref
Expand Down
40 changes: 40 additions & 0 deletions packages/api/src/client/types/app/bsky/graph/getKnownFollowers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* GENERATED CODE - DO NOT MODIFY
*/
import { Headers, XRPCError } from '@atproto/xrpc'
import { ValidationResult, BlobRef } from '@atproto/lexicon'
import { isObj, hasProp } from '../../../../util'
import { lexicons } from '../../../../lexicons'
import { CID } from 'multiformats/cid'
import * as AppBskyActorDefs from '../actor/defs'

export interface QueryParams {
actor: string
limit?: number
cursor?: string
}

export type InputSchema = undefined

export interface OutputSchema {
subject: AppBskyActorDefs.ProfileView
cursor?: string
followers: AppBskyActorDefs.ProfileView[]
[k: string]: unknown
}

export interface CallOptions {
headers?: Headers
}

export interface Response {
success: boolean
headers: Headers
data: OutputSchema
}

export function toKnownErr(e: any) {
if (e instanceof XRPCError) {
}
return e
}
8 changes: 6 additions & 2 deletions packages/bsky/proto/bsky.proto
Original file line number Diff line number Diff line change
Expand Up @@ -972,10 +972,14 @@ message GetRecordTakedownResponse {
// GetFollowsFollowing gets the list of DIDs that the actor follows that also follow the target
message GetFollowsFollowingRequest {
string actor_did = 1;
string target_did = 2;
repeated string target_dids = 2;
}
message FollowsFollowing {
string target_did = 1;
repeated string dids = 2;
}
message GetFollowsFollowingResponse {
repeated string dids = 1;
repeated FollowsFollowing results = 1;
}

// Ping
Expand Down
Loading

0 comments on commit 58abcbd

Please sign in to comment.