Skip to content

Commit

Permalink
Add labels onto record embeds (bluesky-social#854)
Browse files Browse the repository at this point in the history
* Add lexicons for labeling embeds

* Hydrate labels onto record embeds in pds

* Support labels on embeds in bsky appview
  • Loading branch information
devinivy authored Apr 25, 2023
1 parent 68004c6 commit eb7667e
Show file tree
Hide file tree
Showing 17 changed files with 640 additions and 16 deletions.
4 changes: 4 additions & 0 deletions lexicons/app/bsky/embed/record.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"cid": {"type": "string", "format": "cid"},
"author": {"type": "ref", "ref": "app.bsky.actor.defs#profileViewBasic"},
"value": {"type": "unknown"},
"labels": {
"type": "array",
"items": {"type": "ref", "ref": "com.atproto.label.defs#label"}
},
"embeds": {
"type": "array",
"items": {
Expand Down
7 changes: 7 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3816,6 +3816,13 @@ export const schemaDict = {
value: {
type: 'unknown',
},
labels: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.label.defs#label',
},
},
embeds: {
type: 'array',
items: {
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/client/types/app/bsky/embed/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { lexicons } from '../../../../lexicons'
import { CID } from 'multiformats/cid'
import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef'
import * as AppBskyActorDefs from '../actor/defs'
import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs'
import * as AppBskyEmbedImages from './images'
import * as AppBskyEmbedExternal from './external'
import * as AppBskyEmbedRecordWithMedia from './recordWithMedia'
Expand Down Expand Up @@ -49,6 +50,7 @@ export interface ViewRecord {
cid: string
author: AppBskyActorDefs.ProfileViewBasic
value: {}
labels?: ComAtprotoLabelDefs.Label[]
embeds?: (
| AppBskyEmbedImages.View
| AppBskyEmbedExternal.View
Expand Down
7 changes: 7 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3816,6 +3816,13 @@ export const schemaDict = {
value: {
type: 'unknown',
},
labels: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.label.defs#label',
},
},
embeds: {
type: 'array',
items: {
Expand Down
2 changes: 2 additions & 0 deletions packages/bsky/src/lexicon/types/app/bsky/embed/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { isObj, hasProp } from '../../../../util'
import { CID } from 'multiformats/cid'
import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef'
import * as AppBskyActorDefs from '../actor/defs'
import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs'
import * as AppBskyEmbedImages from './images'
import * as AppBskyEmbedExternal from './external'
import * as AppBskyEmbedRecordWithMedia from './recordWithMedia'
Expand Down Expand Up @@ -49,6 +50,7 @@ export interface ViewRecord {
cid: string
author: AppBskyActorDefs.ProfileViewBasic
value: {}
labels?: ComAtprotoLabelDefs.Label[]
embeds?: (
| AppBskyEmbedImages.View
| AppBskyEmbedExternal.View
Expand Down
1 change: 1 addition & 0 deletions packages/bsky/src/services/feed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ export class FeedService {
cid: formatted.cid,
author: formatted.author,
value: formatted.record,
labels: formatted.labels,
embeds: deepEmbeds,
indexedAt: formatted.indexedAt,
}
Expand Down
2 changes: 2 additions & 0 deletions packages/bsky/tests/__snapshots__/indexing.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ Array [
},
"cid": "cids(8)",
"indexedAt": "1970-01-01T00:00:00.000Z",
"labels": Array [],
"uri": "record(9)",
"value": Object {
"$type": "app.bsky.feed.post",
Expand Down Expand Up @@ -257,6 +258,7 @@ Array [
},
],
"indexedAt": "1970-01-01T00:00:00.000Z",
"labels": Array [],
"uri": "record(7)",
"value": Object {
"$type": "app.bsky.feed.post",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ Array [
},
"cid": "cids(7)",
"indexedAt": "1970-01-01T00:00:00.000Z",
"labels": Array [],
"uri": "record(8)",
"value": Object {
"$type": "app.bsky.feed.post",
Expand Down Expand Up @@ -227,6 +228,7 @@ Array [
},
],
"indexedAt": "1970-01-01T00:00:00.000Z",
"labels": Array [],
"uri": "record(6)",
"value": Object {
"$type": "app.bsky.feed.post",
Expand Down Expand Up @@ -585,6 +587,7 @@ Array [
},
"cid": "cids(4)",
"indexedAt": "1970-01-01T00:00:00.000Z",
"labels": Array [],
"uri": "record(2)",
"value": Object {
"$type": "app.bsky.feed.post",
Expand All @@ -596,6 +599,7 @@ Array [
},
],
"indexedAt": "1970-01-01T00:00:00.000Z",
"labels": Array [],
"uri": "record(1)",
"value": Object {
"$type": "app.bsky.feed.post",
Expand Down Expand Up @@ -820,6 +824,7 @@ Array [
"cid": "cids(4)",
"embeds": Array [],
"indexedAt": "1970-01-01T00:00:00.000Z",
"labels": Array [],
"uri": "record(2)",
"value": Object {
"$type": "app.bsky.feed.post",
Expand Down Expand Up @@ -977,6 +982,7 @@ Array [
},
"cid": "cids(6)",
"indexedAt": "1970-01-01T00:00:00.000Z",
"labels": Array [],
"uri": "record(6)",
"value": Object {
"$type": "app.bsky.feed.post",
Expand All @@ -988,6 +994,7 @@ Array [
},
],
"indexedAt": "1970-01-01T00:00:00.000Z",
"labels": Array [],
"uri": "record(5)",
"value": Object {
"$type": "app.bsky.feed.post",
Expand Down Expand Up @@ -1279,6 +1286,7 @@ Array [
},
"cid": "cids(7)",
"indexedAt": "1970-01-01T00:00:00.000Z",
"labels": Array [],
"uri": "record(9)",
"value": Object {
"$type": "app.bsky.feed.post",
Expand Down Expand Up @@ -1325,6 +1333,7 @@ Array [
},
],
"indexedAt": "1970-01-01T00:00:00.000Z",
"labels": Array [],
"uri": "record(8)",
"value": Object {
"$type": "app.bsky.feed.post",
Expand Down
Loading

0 comments on commit eb7667e

Please sign in to comment.