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

Feed interactions schema #2383

Merged
merged 11 commits into from
Apr 11, 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 .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" },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this generally be either a post or repost URI?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now I was thinking it would always be the post uri & any repost that got it in there would be associated through the feedContext that gets sent around 🤔

I left it somewhat vague because I think it's likely we'll start passing down non-post objects in feeds at some point

"event": {
"type": "string",
"knownValues": [
Comment on lines +196 to +198
Copy link
Collaborator

@devinivy devinivy Apr 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have any thoughts on { item: at-uri, event: token, feedContext: string } versus open-union-style { $type, item: at-uri, feedContext: string, ... } I'd be interested to hear! I have a feeling both options crossed your mind 😏

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup that was my first pass on it but then ended up redoing it this way.

Mainly reconsidered because an array of open unions is tough in languages like Go. But also nearly all these interaction types had similar values on them so they were pretty friendly to squash down into a flat object like this so didn't seem like any resolution was lost

"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
Loading
Loading