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

Blocks #922

Merged
merged 32 commits into from
Apr 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9135581
block lexicons
dholms Apr 28, 2023
dce7507
table schema
dholms Apr 28, 2023
ab08472
block processing
dholms Apr 28, 2023
400658d
Actor-block migration
devinivy Apr 28, 2023
ff5a82d
Add blocked post lexicon to getPostThread
devinivy Apr 28, 2023
bb23b4b
getBlocks routes
dholms Apr 28, 2023
dba48d7
Add missing lexicons to bsky
devinivy Apr 28, 2023
e7378a1
Merge branch 'blocks' of github.com:bluesky-social/atproto into blocks
devinivy Apr 28, 2023
b11f1e7
Add block state to actor views
devinivy Apr 28, 2023
fd82024
throw on blocked accounts in getAuthorFeed
dholms Apr 28, 2023
929b8d8
blcok state in profile views
dholms Apr 28, 2023
120ee08
Update getPostThread to support block views, update existing test
devinivy Apr 28, 2023
6f5e13e
strip out blocks out oof timeline & popular
dholms Apr 28, 2023
83fd16d
more routes
dholms Apr 28, 2023
4f5ce3d
Test blocked posts in threads
devinivy Apr 28, 2023
3162afb
Merge branch 'blocks' of github.com:bluesky-social/atproto into blocks
devinivy Apr 28, 2023
93b4420
Support blocks on record embeds
devinivy Apr 28, 2023
a1854d9
notifs
dholms Apr 28, 2023
04b5ee8
Update pds test snapshots w/ block state
devinivy Apr 28, 2023
d784e88
Merge branch 'blocks' of github.com:bluesky-social/atproto into blocks
devinivy Apr 28, 2023
b4238a4
fix search
dholms Apr 28, 2023
6f08d99
Update pds actor search snapshots w/ blocks
devinivy Apr 28, 2023
2922665
test
dholms Apr 28, 2023
88d83b4
tests
dholms Apr 28, 2023
2f21296
update lex
dholms Apr 28, 2023
f0d1fb1
fix up from returning blocking as record
dholms Apr 28, 2023
7b86eab
ci for branch
dholms Apr 28, 2023
55509c4
fix build issue in bsky
dholms Apr 28, 2023
b8b0b84
more blocks tests
dholms Apr 28, 2023
b22aa20
fix actor search test
dholms Apr 28, 2023
a63551d
hook getBlocks up to router
dholms Apr 29, 2023
8c0cd75
bugfix & actually test lol
dholms Apr 29, 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
1 change: 1 addition & 0 deletions .github/workflows/build-and-push-pds-aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- blocks
env:
REGISTRY: ${{ secrets.AWS_ECR_REGISTRY_USEAST2_PACKAGES_REGISTRY }}
USERNAME: ${{ secrets.AWS_ECR_REGISTRY_USEAST2_PACKAGES_USERNAME }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-push-pds-ghcr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- blocks
env:
REGISTRY: ghcr.io
USERNAME: ${{ github.actor }}
Expand Down
2 changes: 2 additions & 0 deletions lexicons/app/bsky/actor/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
"type": "object",
"properties": {
"muted": {"type": "boolean"},
"blockedBy": {"type": "boolean"},
"blocking": {"type": "string", "format": "at-uri"},
"following": {"type": "string", "format": "at-uri"},
"followedBy": {"type": "string", "format": "at-uri"}
}
Expand Down
9 changes: 8 additions & 1 deletion lexicons/app/bsky/embed/record.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"type": "object",
"required": ["record"],
"properties": {
"record": {"type": "union", "refs": ["#viewRecord", "#viewNotFound"]}
"record": {"type": "union", "refs": ["#viewRecord", "#viewNotFound", "#viewBlocked"]}
}
},
"viewRecord": {
Expand Down Expand Up @@ -50,6 +50,13 @@
"properties": {
"uri": {"type": "string", "format": "at-uri"}
}
},
"viewBlocked": {
"type": "object",
"required": ["uri"],
"properties": {
"uri": {"type": "string", "format": "at-uri"}
}
}
}
}
12 changes: 10 additions & 2 deletions lexicons/app/bsky/feed/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@
"required": ["post"],
"properties": {
"post": {"type": "ref", "ref": "#postView"},
"parent": {"type": "union", "refs": ["#threadViewPost", "#notFoundPost"]},
"parent": {"type": "union", "refs": ["#threadViewPost", "#notFoundPost", "#blockedPost"]},
"replies": {
"type": "array",
"items": {"type": "union", "refs": ["#threadViewPost", "#notFoundPost"]}
"items": {"type": "union", "refs": ["#threadViewPost", "#notFoundPost", "#blockedPost"]}
}
}
},
Expand All @@ -81,6 +81,14 @@
"uri": {"type": "string", "format": "at-uri"},
"notFound": {"type": "boolean", "const": true}
}
},
"blockedPost": {
"type": "object",
"required": ["uri", "blocked"],
"properties": {
"uri": {"type": "string", "format": "at-uri"},
"blocked": {"type": "boolean", "const": true}
}
}
}
}
6 changes: 5 additions & 1 deletion lexicons/app/bsky/feed/getAuthorFeed.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
}
}
}
}
},
"errors": [
{"name": "BlockedActor"},
{"name": "BlockedByActor"}
]
}
}
}
6 changes: 5 additions & 1 deletion lexicons/app/bsky/feed/getPostThread.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
"properties": {
"thread": {
"type": "union",
"refs": ["app.bsky.feed.defs#threadViewPost", "app.bsky.feed.defs#notFoundPost"]
"refs": [
"app.bsky.feed.defs#threadViewPost",
"app.bsky.feed.defs#notFoundPost",
"app.bsky.feed.defs#blockedPost"
]
}
}
}
Expand Down
19 changes: 19 additions & 0 deletions lexicons/app/bsky/graph/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"lexicon": 1,
"id": "app.bsky.graph.block",
"defs": {
"main": {
"type": "record",
"description": "A block.",
"key": "tid",
"record": {
"type": "object",
"required": ["subject", "createdAt"],
"properties": {
"subject": {"type": "string", "format": "did"},
"createdAt": {"type": "string", "format": "datetime"}
}
}
}
}
}
31 changes: 31 additions & 0 deletions lexicons/app/bsky/graph/getBlocks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"lexicon": 1,
"id": "app.bsky.graph.getBlocks",
"defs": {
"main": {
"type": "query",
"description": "Who is the requester's account blocking?",
"parameters": {
"type": "params",
"properties": {
"limit": {"type": "integer", "minimum": 1, "maximum": 100, "default": 50},
"cursor": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["blocks"],
"properties": {
"cursor": {"type": "string"},
"blocks": {
"type": "array",
"items": {"type": "ref", "ref": "app.bsky.actor.defs#profileView"}
}
}
}
}
}
}
}
78 changes: 78 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ 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 AppBskyGraphBlock from './types/app/bsky/graph/block'
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 AppBskyGraphGetMutes from './types/app/bsky/graph/getMutes'
Expand Down Expand Up @@ -181,7 +183,9 @@ 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 AppBskyGraphBlock from './types/app/bsky/graph/block'
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 AppBskyGraphGetMutes from './types/app/bsky/graph/getMutes'
Expand Down Expand Up @@ -1339,13 +1343,26 @@ export class RepostRecord {

export class GraphNS {
_service: AtpServiceClient
block: BlockRecord
follow: FollowRecord

constructor(service: AtpServiceClient) {
this._service = service
this.block = new BlockRecord(service)
this.follow = new FollowRecord(service)
}

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

getFollowers(
params?: AppBskyGraphGetFollowers.QueryParams,
opts?: AppBskyGraphGetFollowers.CallOptions,
Expand Down Expand Up @@ -1402,6 +1419,67 @@ export class GraphNS {
}
}

export class BlockRecord {
_service: AtpServiceClient

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

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

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

async create(
params: Omit<
ComAtprotoRepoCreateRecord.InputSchema,
'collection' | 'record'
>,
record: AppBskyGraphBlock.Record,
headers?: Record<string, string>,
): Promise<{ uri: string; cid: string }> {
record.$type = 'app.bsky.graph.block'
const res = await this._service.xrpc.call(
'com.atproto.repo.createRecord',
undefined,
{ collection: 'app.bsky.graph.block', ...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.graph.block', ...params },
{ headers },
)
}
}

export class FollowRecord {
_service: AtpServiceClient

Expand Down
Loading