Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Mar 12, 2024
2 parents 512929b + 7b14660 commit 8a4f668
Show file tree
Hide file tree
Showing 43 changed files with 916 additions and 211 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-and-push-ozone-aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- divert-blobs
env:
REGISTRY: ${{ secrets.AWS_ECR_REGISTRY_USEAST2_PACKAGES_REGISTRY }}
USERNAME: ${{ secrets.AWS_ECR_REGISTRY_USEAST2_PACKAGES_USERNAME }}
Expand Down
4 changes: 4 additions & 0 deletions lexicons/app/bsky/feed/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@
},
"avatar": { "type": "string" },
"likeCount": { "type": "integer", "minimum": 0 },
"labels": {
"type": "array",
"items": { "type": "ref", "ref": "com.atproto.label.defs#label" }
},
"viewer": { "type": "ref", "ref": "#generatorViewerState" },
"indexedAt": { "type": "string", "format": "datetime" }
}
Expand Down
8 changes: 8 additions & 0 deletions lexicons/app/bsky/graph/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"name": { "type": "string", "maxLength": 64, "minLength": 1 },
"purpose": { "type": "ref", "ref": "#listPurpose" },
"avatar": { "type": "string" },
"labels": {
"type": "array",
"items": { "type": "ref", "ref": "com.atproto.label.defs#label" }
},
"viewer": { "type": "ref", "ref": "#listViewerState" },
"indexedAt": { "type": "string", "format": "datetime" }
}
Expand All @@ -34,6 +38,10 @@
"items": { "type": "ref", "ref": "app.bsky.richtext.facet" }
},
"avatar": { "type": "string" },
"labels": {
"type": "array",
"items": { "type": "ref", "ref": "com.atproto.label.defs#label" }
},
"viewer": { "type": "ref", "ref": "#listViewerState" },
"indexedAt": { "type": "string", "format": "datetime" }
}
Expand Down
13 changes: 11 additions & 2 deletions lexicons/com/atproto/admin/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"#modEventEscalate",
"#modEventMute",
"#modEventEmail",
"#modEventResolveAppeal"
"#modEventResolveAppeal",
"#modEventDivert"
]
},
"subject": {
Expand Down Expand Up @@ -72,7 +73,8 @@
"#modEventEscalate",
"#modEventMute",
"#modEventEmail",
"#modEventResolveAppeal"
"#modEventResolveAppeal",
"#modEventDivert"
]
},
"subject": {
Expand Down Expand Up @@ -625,6 +627,13 @@
}
}
},
"modEventDivert": {
"type": "object",
"description": "Divert a record's blobs to a 3rd party service for further scanning/tagging",
"properties": {
"comment": { "type": "string" }
}
},
"communicationTemplateView": {
"type": "object",
"required": [
Expand Down
33 changes: 33 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const schemaDict = {
'lex:com.atproto.admin.defs#modEventMute',
'lex:com.atproto.admin.defs#modEventEmail',
'lex:com.atproto.admin.defs#modEventResolveAppeal',
'lex:com.atproto.admin.defs#modEventDivert',
],
},
subject: {
Expand Down Expand Up @@ -150,6 +151,7 @@ export const schemaDict = {
'lex:com.atproto.admin.defs#modEventMute',
'lex:com.atproto.admin.defs#modEventEmail',
'lex:com.atproto.admin.defs#modEventResolveAppeal',
'lex:com.atproto.admin.defs#modEventDivert',
],
},
subject: {
Expand Down Expand Up @@ -940,6 +942,16 @@ export const schemaDict = {
},
},
},
modEventDivert: {
type: 'object',
description:
"Divert a record's blobs to a 3rd party service for further scanning/tagging",
properties: {
comment: {
type: 'string',
},
},
},
communicationTemplateView: {
type: 'object',
required: [
Expand Down Expand Up @@ -6310,6 +6322,13 @@ export const schemaDict = {
type: 'integer',
minimum: 0,
},
labels: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.label.defs#label',
},
},
viewer: {
type: 'ref',
ref: 'lex:app.bsky.feed.defs#generatorViewerState',
Expand Down Expand Up @@ -7614,6 +7633,13 @@ export const schemaDict = {
avatar: {
type: 'string',
},
labels: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.label.defs#label',
},
},
viewer: {
type: 'ref',
ref: 'lex:app.bsky.graph.defs#listViewerState',
Expand Down Expand Up @@ -7664,6 +7690,13 @@ export const schemaDict = {
avatar: {
type: 'string',
},
labels: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.label.defs#label',
},
},
viewer: {
type: 'ref',
ref: 'lex:app.bsky.graph.defs#listViewerState',
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/client/types/app/bsky/feed/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export interface GeneratorView {
descriptionFacets?: AppBskyRichtextFacet.Main[]
avatar?: string
likeCount?: number
labels?: ComAtprotoLabelDefs.Label[]
viewer?: GeneratorViewerState
indexedAt: string
[k: string]: unknown
Expand Down
3 changes: 3 additions & 0 deletions packages/api/src/client/types/app/bsky/graph/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ValidationResult, BlobRef } from '@atproto/lexicon'
import { isObj, hasProp } from '../../../../util'
import { lexicons } from '../../../../lexicons'
import { CID } from 'multiformats/cid'
import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs'
import * as AppBskyActorDefs from '../actor/defs'
import * as AppBskyRichtextFacet from '../richtext/facet'

Expand All @@ -14,6 +15,7 @@ export interface ListViewBasic {
name: string
purpose: ListPurpose
avatar?: string
labels?: ComAtprotoLabelDefs.Label[]
viewer?: ListViewerState
indexedAt?: string
[k: string]: unknown
Expand All @@ -40,6 +42,7 @@ export interface ListView {
description?: string
descriptionFacets?: AppBskyRichtextFacet.Main[]
avatar?: string
labels?: ComAtprotoLabelDefs.Label[]
viewer?: ListViewerState
indexedAt: string
[k: string]: unknown
Expand Down
20 changes: 20 additions & 0 deletions packages/api/src/client/types/com/atproto/admin/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface ModEventView {
| ModEventMute
| ModEventEmail
| ModEventResolveAppeal
| ModEventDivert
| { $type: string; [k: string]: unknown }
subject:
| RepoRef
Expand Down Expand Up @@ -79,6 +80,7 @@ export interface ModEventViewDetail {
| ModEventMute
| ModEventEmail
| ModEventResolveAppeal
| ModEventDivert
| { $type: string; [k: string]: unknown }
subject:
| RepoView
Expand Down Expand Up @@ -749,6 +751,24 @@ export function validateModEventTag(v: unknown): ValidationResult {
return lexicons.validate('com.atproto.admin.defs#modEventTag', v)
}

/** Divert a record's blobs to a 3rd party service for further scanning/tagging */
export interface ModEventDivert {
comment?: string
[k: string]: unknown
}

export function isModEventDivert(v: unknown): v is ModEventDivert {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'com.atproto.admin.defs#modEventDivert'
)
}

export function validateModEventDivert(v: unknown): ValidationResult {
return lexicons.validate('com.atproto.admin.defs#modEventDivert', v)
}

export interface CommunicationTemplateView {
id: string
/** Name of the template. */
Expand Down
13 changes: 10 additions & 3 deletions packages/bsky/src/api/com/atproto/admin/getAccountInfos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@ import { INVALID_HANDLE } from '@atproto/syntax'

export default function (server: Server, ctx: AppContext) {
server.com.atproto.admin.getAccountInfos({
auth: ctx.authVerifier.roleOrModService,
handler: async ({ params }) => {
auth: ctx.authVerifier.optionalStandardOrRole,
handler: async ({ params, auth }) => {
const { dids } = params
const { canViewTakedowns } = ctx.authVerifier.parseCreds(auth)

const actors = await ctx.hydrator.actor.getActors(dids, true)

const infos = mapDefined(dids, (did) => {
const info = actors.get(did)
if (!info) return
if (info.takedownRef && !canViewTakedowns) return
const profileRecord =
!info.profileTakedownRef || canViewTakedowns
? info.profile
: undefined
return {
did,
handle: info.handle ?? INVALID_HANDLE,
relatedRecords: info.profile ? [info.profile] : undefined,
relatedRecords: profileRecord ? [profileRecord] : undefined,
indexedAt: (info.sortedAt ?? new Date(0)).toISOString(),
}
})
Expand Down
6 changes: 3 additions & 3 deletions packages/bsky/src/hydration/hydrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export class Hydrator {
actionTakedownLabels(uris, lists, labels)
}

return { lists, listViewers, ctx }
return { lists, listViewers, labels, ctx }
}

// app.bsky.graph.defs#listItemView
Expand Down Expand Up @@ -305,7 +305,7 @@ export class Hydrator {
] = await Promise.all([
this.feed.getPostAggregates(refs),
ctx.viewer ? this.feed.getPostViewerStates(refs, ctx.viewer) : undefined,
this.label.getLabelsForSubjects(allPostUris, ctx.labelers),
this.label.getLabelsForSubjects(allPostUris, ctx.labelers.dids),
this.hydratePostBlocks(posts),
this.hydrateProfiles(allPostUris.map(didFromUri), ctx),
this.hydrateLists([...nestedListUris, ...gateListUris], ctx),
Expand Down Expand Up @@ -501,7 +501,7 @@ export class Hydrator {
this.feed.getLikes(likeUris), // reason: like
this.feed.getReposts(repostUris), // reason: repost
this.graph.getFollows(followUris), // reason: follow
this.label.getLabelsForSubjects(uris, ctx.labelers),
this.label.getLabelsForSubjects(uris, ctx.labelers.dids),
this.hydrateProfiles(uris.map(didFromUri), ctx),
])
actionTakedownLabels(postUris, posts, labels)
Expand Down
5 changes: 3 additions & 2 deletions packages/bsky/src/hydration/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ export class LabelHydrator {
issuers: labelers.dids,
})
return res.labels.reduce((acc, cur) => {
const label = parseJsonBytes(cur) as Label | undefined
if (!label || label.neg) return acc
const parsed = parseJsonBytes(cur) as Label | undefined
if (!parsed || parsed.neg) return acc
const { sig: _, ...label } = parsed
let entry = acc.get(label.uri)
if (!entry) {
entry = {
Expand Down
33 changes: 33 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const schemaDict = {
'lex:com.atproto.admin.defs#modEventMute',
'lex:com.atproto.admin.defs#modEventEmail',
'lex:com.atproto.admin.defs#modEventResolveAppeal',
'lex:com.atproto.admin.defs#modEventDivert',
],
},
subject: {
Expand Down Expand Up @@ -150,6 +151,7 @@ export const schemaDict = {
'lex:com.atproto.admin.defs#modEventMute',
'lex:com.atproto.admin.defs#modEventEmail',
'lex:com.atproto.admin.defs#modEventResolveAppeal',
'lex:com.atproto.admin.defs#modEventDivert',
],
},
subject: {
Expand Down Expand Up @@ -940,6 +942,16 @@ export const schemaDict = {
},
},
},
modEventDivert: {
type: 'object',
description:
"Divert a record's blobs to a 3rd party service for further scanning/tagging",
properties: {
comment: {
type: 'string',
},
},
},
communicationTemplateView: {
type: 'object',
required: [
Expand Down Expand Up @@ -6310,6 +6322,13 @@ export const schemaDict = {
type: 'integer',
minimum: 0,
},
labels: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.label.defs#label',
},
},
viewer: {
type: 'ref',
ref: 'lex:app.bsky.feed.defs#generatorViewerState',
Expand Down Expand Up @@ -7614,6 +7633,13 @@ export const schemaDict = {
avatar: {
type: 'string',
},
labels: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.label.defs#label',
},
},
viewer: {
type: 'ref',
ref: 'lex:app.bsky.graph.defs#listViewerState',
Expand Down Expand Up @@ -7664,6 +7690,13 @@ export const schemaDict = {
avatar: {
type: 'string',
},
labels: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.label.defs#label',
},
},
viewer: {
type: 'ref',
ref: 'lex:app.bsky.graph.defs#listViewerState',
Expand Down
1 change: 1 addition & 0 deletions packages/bsky/src/lexicon/types/app/bsky/feed/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export interface GeneratorView {
descriptionFacets?: AppBskyRichtextFacet.Main[]
avatar?: string
likeCount?: number
labels?: ComAtprotoLabelDefs.Label[]
viewer?: GeneratorViewerState
indexedAt: string
[k: string]: unknown
Expand Down
3 changes: 3 additions & 0 deletions packages/bsky/src/lexicon/types/app/bsky/graph/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ValidationResult, BlobRef } from '@atproto/lexicon'
import { lexicons } from '../../../../lexicons'
import { isObj, hasProp } from '../../../../util'
import { CID } from 'multiformats/cid'
import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs'
import * as AppBskyActorDefs from '../actor/defs'
import * as AppBskyRichtextFacet from '../richtext/facet'

Expand All @@ -14,6 +15,7 @@ export interface ListViewBasic {
name: string
purpose: ListPurpose
avatar?: string
labels?: ComAtprotoLabelDefs.Label[]
viewer?: ListViewerState
indexedAt?: string
[k: string]: unknown
Expand All @@ -40,6 +42,7 @@ export interface ListView {
description?: string
descriptionFacets?: AppBskyRichtextFacet.Main[]
avatar?: string
labels?: ComAtprotoLabelDefs.Label[]
viewer?: ListViewerState
indexedAt: string
[k: string]: unknown
Expand Down
Loading

0 comments on commit 8a4f668

Please sign in to comment.