Skip to content

Commit

Permalink
Feed interactions schema (#2383)
Browse files Browse the repository at this point in the history
* first pass schemas

* requestFeedback boolean

* rewrite schemas

* tidy

* tidy

* tweaks

* pr feedback

* codegen + lint

* changeset

* rm default
  • Loading branch information
dholms committed Apr 11, 2024
1 parent 84cdc5b commit 0edef0e
Show file tree
Hide file tree
Showing 27 changed files with 1,236 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-terms-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@atproto/api': patch
---

Added feed generator interaction lexicons
91 changes: 89 additions & 2 deletions lexicons/app/bsky/feed/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@
"properties": {
"post": { "type": "ref", "ref": "#postView" },
"reply": { "type": "ref", "ref": "#replyRef" },
"reason": { "type": "union", "refs": ["#reasonRepost"] }
"reason": { "type": "union", "refs": ["#reasonRepost"] },
"feedContext": {
"type": "string",
"description": "Context provided by feed generator that may be passed back alongside interactions.",
"maxLength": 2000
}
}
},
"replyRef": {
Expand Down Expand Up @@ -137,6 +142,7 @@
},
"avatar": { "type": "string", "format": "uri" },
"likeCount": { "type": "integer", "minimum": 0 },
"acceptsInteractions": { "type": "boolean" },
"labels": {
"type": "array",
"items": { "type": "ref", "ref": "com.atproto.label.defs#label" }
Expand All @@ -156,7 +162,12 @@
"required": ["post"],
"properties": {
"post": { "type": "string", "format": "at-uri" },
"reason": { "type": "union", "refs": ["#skeletonReasonRepost"] }
"reason": { "type": "union", "refs": ["#skeletonReasonRepost"] },
"feedContext": {
"type": "string",
"description": "Context that will be passed through to client and may be passed to feed generator back alongside interactions.",
"maxLength": 2000
}
}
},
"skeletonReasonRepost": {
Expand All @@ -177,6 +188,82 @@
"items": { "type": "ref", "ref": "app.bsky.graph.defs#listViewBasic" }
}
}
},
"interaction": {
"type": "object",
"properties": {
"item": { "type": "string", "format": "at-uri" },
"event": {
"type": "string",
"knownValues": [
"app.bsky.feed.defs#requestLess",
"app.bsky.feed.defs#requestMore",
"app.bsky.feed.defs#clickthroughItem",
"app.bsky.feed.defs#clickthroughAuthor",
"app.bsky.feed.defs#clickthroughReposter",
"app.bsky.feed.defs#clickthroughEmbed",
"app.bsky.feed.defs#interactionSeen",
"app.bsky.feed.defs#interactionLike",
"app.bsky.feed.defs#interactionRepost",
"app.bsky.feed.defs#interactionReply",
"app.bsky.feed.defs#interactionQuote",
"app.bsky.feed.defs#interactionShare"
]
},
"feedContext": {
"type": "string",
"description": "Context on a feed item that was orginally supplied by the feed generator on getFeedSkeleton.",
"maxLength": 2000
}
}
},
"requestLess": {
"type": "token",
"description": "Request that less content like the given feed item be shown in the feed"
},
"requestMore": {
"type": "token",
"description": "Request that more content like the given feed item be shown in the feed"
},
"clickthroughItem": {
"type": "token",
"description": "User clicked through to the feed item"
},
"clickthroughAuthor": {
"type": "token",
"description": "User clicked through to the author of the feed item"
},
"clickthroughReposter": {
"type": "token",
"description": "User clicked through to the reposter of the feed item"
},
"clickthroughEmbed": {
"type": "token",
"description": "User clicked through to the embedded content of the feed item"
},
"interactionSeen": {
"type": "token",
"description": "Feed item was seen by user"
},
"interactionLike": {
"type": "token",
"description": "User liked the feed item"
},
"interactionRepost": {
"type": "token",
"description": "User reposted the feed item"
},
"interactionReply": {
"type": "token",
"description": "User replied to the feed item"
},
"interactionQuote": {
"type": "token",
"description": "User quoted the feed item"
},
"interactionShare": {
"type": "token",
"description": "User shared the feed item"
}
}
}
4 changes: 4 additions & 0 deletions lexicons/app/bsky/feed/generator.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
"accept": ["image/png", "image/jpeg"],
"maxSize": 1000000
},
"acceptsInteractions": {
"type": "boolean",
"description": "Declaration that a feed accepts feedback interactions from a client through app.bsky.feed.sendInteractions"
},
"labels": {
"type": "union",
"description": "Self-label values",
Expand Down
33 changes: 33 additions & 0 deletions lexicons/app/bsky/feed/sendInteractions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"lexicon": 1,
"id": "app.bsky.feed.sendInteractions",
"defs": {
"main": {
"type": "procedure",
"description": "Send information about interactions with feed items back to the feed generator that served them.",
"input": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["interactions"],
"properties": {
"interactions": {
"type": "array",
"items": {
"type": "ref",
"ref": "app.bsky.feed.defs#interaction"
}
}
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"properties": {}
}
}
}
}
}
2 changes: 1 addition & 1 deletion packages/api/jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ expect.extend({
toBeModerationResult(
actual: ModerationUI,
expected: ModerationTestSuiteResultFlag[] | undefined,
context: string = '',
context = '',
stringifiedResult: string | undefined = undefined,
_ignoreCause = false,
) {
Expand Down
27 changes: 27 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ import * as AppBskyFeedLike from './types/app/bsky/feed/like'
import * as AppBskyFeedPost from './types/app/bsky/feed/post'
import * as AppBskyFeedRepost from './types/app/bsky/feed/repost'
import * as AppBskyFeedSearchPosts from './types/app/bsky/feed/searchPosts'
import * as AppBskyFeedSendInteractions from './types/app/bsky/feed/sendInteractions'
import * as AppBskyFeedThreadgate from './types/app/bsky/feed/threadgate'
import * as AppBskyGraphBlock from './types/app/bsky/graph/block'
import * as AppBskyGraphDefs from './types/app/bsky/graph/defs'
Expand Down Expand Up @@ -277,6 +278,7 @@ export * as AppBskyFeedLike from './types/app/bsky/feed/like'
export * as AppBskyFeedPost from './types/app/bsky/feed/post'
export * as AppBskyFeedRepost from './types/app/bsky/feed/repost'
export * as AppBskyFeedSearchPosts from './types/app/bsky/feed/searchPosts'
export * as AppBskyFeedSendInteractions from './types/app/bsky/feed/sendInteractions'
export * as AppBskyFeedThreadgate from './types/app/bsky/feed/threadgate'
export * as AppBskyGraphBlock from './types/app/bsky/graph/block'
export * as AppBskyGraphDefs from './types/app/bsky/graph/defs'
Expand Down Expand Up @@ -334,6 +336,20 @@ export const COM_ATPROTO_MODERATION = {
DefsReasonOther: 'com.atproto.moderation.defs#reasonOther',
DefsReasonAppeal: 'com.atproto.moderation.defs#reasonAppeal',
}
export const APP_BSKY_FEED = {
DefsRequestLess: 'app.bsky.feed.defs#requestLess',
DefsRequestMore: 'app.bsky.feed.defs#requestMore',
DefsClickthroughItem: 'app.bsky.feed.defs#clickthroughItem',
DefsClickthroughAuthor: 'app.bsky.feed.defs#clickthroughAuthor',
DefsClickthroughReposter: 'app.bsky.feed.defs#clickthroughReposter',
DefsClickthroughEmbed: 'app.bsky.feed.defs#clickthroughEmbed',
DefsInteractionSeen: 'app.bsky.feed.defs#interactionSeen',
DefsInteractionLike: 'app.bsky.feed.defs#interactionLike',
DefsInteractionRepost: 'app.bsky.feed.defs#interactionRepost',
DefsInteractionReply: 'app.bsky.feed.defs#interactionReply',
DefsInteractionQuote: 'app.bsky.feed.defs#interactionQuote',
DefsInteractionShare: 'app.bsky.feed.defs#interactionShare',
}
export const APP_BSKY_GRAPH = {
DefsModlist: 'app.bsky.graph.defs#modlist',
DefsCuratelist: 'app.bsky.graph.defs#curatelist',
Expand Down Expand Up @@ -1637,6 +1653,17 @@ export class AppBskyFeedNS {
throw AppBskyFeedSearchPosts.toKnownErr(e)
})
}

sendInteractions(
data?: AppBskyFeedSendInteractions.InputSchema,
opts?: AppBskyFeedSendInteractions.CallOptions,
): Promise<AppBskyFeedSendInteractions.Response> {
return this._service.xrpc
.call('app.bsky.feed.sendInteractions', opts?.qp, data, opts)
.catch((e) => {
throw AppBskyFeedSendInteractions.toKnownErr(e)
})
}
}

export class GeneratorRecord {
Expand Down

0 comments on commit 0edef0e

Please sign in to comment.