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

Interaction Gating #1561

Merged
merged 79 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
d7ee9f3
lexicons for block lists
devinivy Aug 28, 2023
a21aa90
reorg blockset functionality into graph service, impl block/mute filt…
devinivy Aug 29, 2023
1a5eae2
apply filterBlocksAndMutes() throughout appview except feeds
devinivy Aug 29, 2023
15d1220
update local feeds to pass through cleanFeedSkeleton(), offload block…
devinivy Aug 29, 2023
b194a58
impl for grabbing block/mute details by did pair
devinivy Aug 30, 2023
0dc8413
refactor getActorInfos away, use actor service
devinivy Aug 30, 2023
c6385f1
Merge remote-tracking branch 'origin/main' into block-lists-redux-redux
devinivy Aug 30, 2023
d571bfe
experiment with moving getFeedGenerators over to a pipeline
devinivy Aug 30, 2023
890c9fc
move getPostThread over to a pipeline
devinivy Aug 30, 2023
57fbaa2
move feeds over to pipelines
devinivy Aug 31, 2023
6712b2e
move suggestions and likes over to pipelines
devinivy Aug 31, 2023
b550d1d
move reposted-by, follows, followers over to pipelines, tidy author f…
devinivy Aug 31, 2023
4f4580c
remove old block/mute checks
devinivy Aug 31, 2023
9801663
unify post presentation logic
devinivy Aug 31, 2023
2a1eced
move profiles endpoints over to pipelines
devinivy Aug 31, 2023
8a72f5a
tidy
devinivy Aug 31, 2023
e5b51c2
tidy
devinivy Sep 1, 2023
541c6c0
Merge remote-tracking branch 'origin/main' into block-lists-redux-redux
devinivy Sep 1, 2023
7ab70f9
Merge remote-tracking branch 'origin/block-lists-redux-redux' into bl…
devinivy Sep 1, 2023
cdcc26b
misc fixes
devinivy Sep 1, 2023
992c25f
unify some profile hydration/presentation in appview
devinivy Sep 1, 2023
da221b0
profile detail, split hydration and presentation, misc fixes
devinivy Sep 2, 2023
a353624
unify feed hydration w/ profile hydration
devinivy Sep 4, 2023
0015729
unify hydration step for embeds, tidy application of labels
devinivy Sep 4, 2023
32f826e
setup indexing of list-blocks in bsky appview
devinivy Sep 4, 2023
ec21246
apply list-blocks, impl getListBlocks, tidy getList, tests
devinivy Sep 5, 2023
eb30fd1
tidy
devinivy Sep 5, 2023
8711f6c
update pds proxy snaps
devinivy Sep 5, 2023
a27b532
Merge remote-tracking branch 'origin/block-lists-redux-redux-pipeline…
devinivy Sep 5, 2023
0265e49
update pds proxy snaps
devinivy Sep 5, 2023
280eb5a
fix snap
devinivy Sep 5, 2023
0dfa73b
make algos return feed items, save work in getFeed
devinivy Sep 6, 2023
0259785
misc changes, tidy
devinivy Sep 6, 2023
c84bc28
tidy
devinivy Sep 6, 2023
c645ed7
Merge pull request #1547 from bluesky-social/block-lists-redux-redux-…
devinivy Sep 6, 2023
d01ae4a
Merge remote-tracking branch 'origin/block-lists-redux-redux' into bl…
devinivy Sep 6, 2023
d704510
Merge branch 'main' into block-lists-redux-redux
dholms Sep 6, 2023
f4918c8
Merge pull request #1549 from bluesky-social/block-lists-redux-redux-…
devinivy Sep 6, 2023
447d7a5
fix aturi import
devinivy Sep 6, 2023
2a8e48b
initial lexicons for interaction-gating
devinivy Sep 5, 2023
9b7743c
add interactions view to post views
devinivy Sep 6, 2023
a910034
codegen
devinivy Sep 6, 2023
1656335
model bad reply/interaction check state on posts
devinivy Sep 6, 2023
e916b5c
initial impl for checking bad reply or interaction on write
devinivy Sep 6, 2023
3eb6e63
omit invalid interactions from post thread
devinivy Sep 6, 2023
0e560ea
support not-found list in interaction view
devinivy Sep 7, 2023
aec42a2
hydrate can-reply state on threads
devinivy Sep 7, 2023
e3cf14d
present interaction views on posts
devinivy Sep 7, 2023
cea6ff0
misc fixes, update snaps
devinivy Sep 7, 2023
aa49fbb
tidy/reorg
devinivy Sep 7, 2023
04c738f
tidy
devinivy Sep 7, 2023
d7c6dce
split interaction gating into separate record in lexicon
devinivy Sep 8, 2023
9e74667
switch interaction-gating impl to use separate record type
devinivy Sep 8, 2023
76cc20d
allow checking reply gate w/ root post deletion
devinivy Sep 8, 2023
8d6e0b4
fix
devinivy Sep 8, 2023
29b5ebb
initial gating tests
devinivy Sep 8, 2023
0ab206e
tighten gated reply views, tests
devinivy Sep 8, 2023
50b1875
reply-gating list rule tests
devinivy Sep 8, 2023
f0133f2
allow custom post rkeys within window
devinivy Sep 8, 2023
642f975
Merge remote-tracking branch 'origin/main' into block-lists-redux-redux
devinivy Sep 8, 2023
0535368
hoist actors out of composeThread()
devinivy Sep 8, 2023
cb30cff
tidy
devinivy Sep 8, 2023
31a7306
Merge remote-tracking branch 'origin/block-lists-redux-redux' into in…
devinivy Sep 11, 2023
c2740a3
update thread gate lexicons, codegen
devinivy Sep 11, 2023
25fc209
lex fix
devinivy Sep 11, 2023
b94477c
rename gate to threadgate in bsky, update views
devinivy Sep 11, 2023
52b5972
lex fix
devinivy Sep 11, 2023
60bbeb6
improve terminology around reply validation
devinivy Sep 11, 2023
6a8eaba
fix down migration
devinivy Sep 11, 2023
30ca7f0
remove thread gates on actor unindexing
devinivy Sep 11, 2023
cd54186
add back .prettierignore
devinivy Sep 11, 2023
edee5a6
tidy
devinivy Sep 11, 2023
d11ecd8
run ci on all prs
dholms Sep 12, 2023
5218ab9
syntax
dholms Sep 12, 2023
51cd347
run ci on all prs
dholms Sep 12, 2023
bd6a7a6
Merge branch 'block-lists-redux-redux' into interaction-gating-init
dholms Sep 12, 2023
79cb410
format
dholms Sep 12, 2023
1f852b2
merge main
dholms Sep 14, 2023
d6bdcab
fix snap
dholms Sep 14, 2023
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
24 changes: 22 additions & 2 deletions lexicons/app/bsky/feed/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"labels": {
"type": "array",
"items": { "type": "ref", "ref": "com.atproto.label.defs#label" }
}
},
"threadgate": { "type": "ref", "ref": "#threadgateView" }
}
},
"viewerState": {
Expand Down Expand Up @@ -86,7 +87,8 @@
"type": "union",
"refs": ["#threadViewPost", "#notFoundPost", "#blockedPost"]
}
}
},
"viewer": { "type": "ref", "ref": "#viewerThreadState" }
}
},
"notFoundPost": {
Expand Down Expand Up @@ -114,6 +116,12 @@
"viewer": { "type": "ref", "ref": "app.bsky.actor.defs#viewerState" }
}
},
"viewerThreadState": {
"type": "object",
"properties": {
"canReply": { "type": "boolean" }
}
},
"generatorView": {
"type": "object",
"required": ["uri", "cid", "did", "creator", "displayName", "indexedAt"],
Expand Down Expand Up @@ -158,6 +166,18 @@
"properties": {
"repost": { "type": "string", "format": "at-uri" }
}
},
"threadgateView": {
"type": "object",
"properties": {
"uri": { "type": "string", "format": "at-uri" },
"cid": { "type": "string", "format": "cid" },
"record": { "type": "unknown" },
"lists": {
"type": "array",
"items": { "type": "ref", "ref": "app.bsky.graph.defs#listViewBasic" }
}
}
}
}
}
43 changes: 43 additions & 0 deletions lexicons/app/bsky/feed/threadgate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"lexicon": 1,
"id": "app.bsky.feed.threadgate",
"defs": {
"main": {
"type": "record",
"key": "tid",
"description": "Defines interaction gating rules for a thread. The rkey of the threadgate record should match the rkey of the thread's root post.",
"record": {
"type": "object",
"required": ["post", "createdAt"],
"properties": {
"post": { "type": "string", "format": "at-uri" },
"allow": {
"type": "array",
"maxLength": 5,
"items": {
"type": "union",
"refs": ["#mentionRule", "#followingRule", "#listRule"]
}
},
"createdAt": { "type": "string", "format": "datetime" }
}
}
},
"mentionRule": {
"type": "object",
"description": "Allow replies from actors mentioned in your post."
},
"followingRule": {
"type": "object",
"description": "Allow replies from actors you follow."
},
Comment on lines +26 to +33
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't object types supposed to have 1 or more properties? I maintain a lexicon codegen plugin and I noticed it's choking on these new types

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah looks like it was already reported: #1615

"listRule": {
"type": "object",
"description": "Allow replies from actors on a list.",
"required": ["list"],
"properties": {
"list": { "type": "string", "format": "at-uri" }
}
}
}
}
69 changes: 69 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import * as AppBskyFeedGetTimeline from './types/app/bsky/feed/getTimeline'
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 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'
import * as AppBskyGraphFollow from './types/app/bsky/graph/follow'
Expand Down Expand Up @@ -228,6 +229,7 @@ export * as AppBskyFeedGetTimeline from './types/app/bsky/feed/getTimeline'
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 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'
export * as AppBskyGraphFollow from './types/app/bsky/graph/follow'
Expand Down Expand Up @@ -1204,13 +1206,15 @@ export class FeedNS {
like: LikeRecord
post: PostRecord
repost: RepostRecord
threadgate: ThreadgateRecord

constructor(service: AtpServiceClient) {
this._service = service
this.generator = new GeneratorRecord(service)
this.like = new LikeRecord(service)
this.post = new PostRecord(service)
this.repost = new RepostRecord(service)
this.threadgate = new ThreadgateRecord(service)
}

describeFeedGenerator(
Expand Down Expand Up @@ -1623,6 +1627,71 @@ export class RepostRecord {
}
}

export class ThreadgateRecord {
_service: AtpServiceClient

constructor(service: AtpServiceClient) {
this._service = service
}

async list(
params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>,
): Promise<{
cursor?: string
records: { uri: string; value: AppBskyFeedThreadgate.Record }[]
}> {
const res = await this._service.xrpc.call('com.atproto.repo.listRecords', {
collection: 'app.bsky.feed.threadgate',
...params,
})
return res.data
}

async get(
params: Omit<ComAtprotoRepoGetRecord.QueryParams, 'collection'>,
): Promise<{
uri: string
cid: string
value: AppBskyFeedThreadgate.Record
}> {
const res = await this._service.xrpc.call('com.atproto.repo.getRecord', {
collection: 'app.bsky.feed.threadgate',
...params,
})
return res.data
}

async create(
params: Omit<
ComAtprotoRepoCreateRecord.InputSchema,
'collection' | 'record'
>,
record: AppBskyFeedThreadgate.Record,
headers?: Record<string, string>,
): Promise<{ uri: string; cid: string }> {
record.$type = 'app.bsky.feed.threadgate'
const res = await this._service.xrpc.call(
'com.atproto.repo.createRecord',
undefined,
{ collection: 'app.bsky.feed.threadgate', ...params, record },
{ encoding: 'application/json', headers },
)
return res.data
}

async delete(
params: Omit<ComAtprotoRepoDeleteRecord.InputSchema, 'collection'>,
headers?: Record<string, string>,
): Promise<void> {
await this._service.xrpc.call(
'com.atproto.repo.deleteRecord',
undefined,
{ collection: 'app.bsky.feed.threadgate', ...params },
{ headers },
)
}
}

export class GraphNS {
_service: AtpServiceClient
block: BlockRecord
Expand Down
97 changes: 97 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4390,6 +4390,10 @@ export const schemaDict = {
ref: 'lex:com.atproto.label.defs#label',
},
},
threadgate: {
type: 'ref',
ref: 'lex:app.bsky.feed.defs#threadgateView',
},
},
},
viewerState: {
Expand Down Expand Up @@ -4486,6 +4490,10 @@ export const schemaDict = {
],
},
},
viewer: {
type: 'ref',
ref: 'lex:app.bsky.feed.defs#viewerThreadState',
},
},
},
notFoundPost: {
Expand Down Expand Up @@ -4534,6 +4542,14 @@ export const schemaDict = {
},
},
},
viewerThreadState: {
type: 'object',
properties: {
canReply: {
type: 'boolean',
},
},
},
generatorView: {
type: 'object',
required: ['uri', 'cid', 'did', 'creator', 'displayName', 'indexedAt'],
Expand Down Expand Up @@ -4619,6 +4635,29 @@ export const schemaDict = {
},
},
},
threadgateView: {
type: 'object',
properties: {
uri: {
type: 'string',
format: 'at-uri',
},
cid: {
type: 'string',
format: 'cid',
},
record: {
type: 'unknown',
},
lists: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:app.bsky.graph.defs#listViewBasic',
},
},
},
},
},
},
AppBskyFeedDescribeFeedGenerator: {
Expand Down Expand Up @@ -5615,6 +5654,63 @@ export const schemaDict = {
},
},
},
AppBskyFeedThreadgate: {
lexicon: 1,
id: 'app.bsky.feed.threadgate',
defs: {
main: {
type: 'record',
key: 'tid',
description:
"Defines interaction gating rules for a thread. The rkey of the threadgate record should match the rkey of the thread's root post.",
record: {
type: 'object',
required: ['post', 'createdAt'],
properties: {
post: {
type: 'string',
format: 'at-uri',
},
allow: {
type: 'array',
maxLength: 5,
items: {
type: 'union',
refs: [
'lex:app.bsky.feed.threadgate#mentionRule',
'lex:app.bsky.feed.threadgate#followingRule',
'lex:app.bsky.feed.threadgate#listRule',
],
},
},
createdAt: {
type: 'string',
format: 'datetime',
},
},
},
},
mentionRule: {
type: 'object',
description: 'Allow replies from actors mentioned in your post.',
},
followingRule: {
type: 'object',
description: 'Allow replies from actors you follow.',
},
listRule: {
type: 'object',
description: 'Allow replies from actors on a list.',
required: ['list'],
properties: {
list: {
type: 'string',
format: 'at-uri',
},
},
},
},
},
AppBskyGraphBlock: {
lexicon: 1,
id: 'app.bsky.graph.block',
Expand Down Expand Up @@ -6932,6 +7028,7 @@ export const ids = {
AppBskyFeedLike: 'app.bsky.feed.like',
AppBskyFeedPost: 'app.bsky.feed.post',
AppBskyFeedRepost: 'app.bsky.feed.repost',
AppBskyFeedThreadgate: 'app.bsky.feed.threadgate',
AppBskyGraphBlock: 'app.bsky.graph.block',
AppBskyGraphDefs: 'app.bsky.graph.defs',
AppBskyGraphFollow: 'app.bsky.graph.follow',
Expand Down
Loading
Loading