Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Mar 11, 2024
2 parents 3060b43 + 877906f commit 5fe83bf
Show file tree
Hide file tree
Showing 66 changed files with 611 additions and 123 deletions.
13 changes: 13 additions & 0 deletions lexicons/com/atproto/label/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"description": "Metadata tag on an atproto resource (eg, repo or record).",
"required": ["src", "uri", "val", "cts"],
"properties": {
"ver": {
"type": "integer",
"description": "The AT Protocol version of the label object."
},
"src": {
"type": "string",
"format": "did",
Expand Down Expand Up @@ -35,6 +39,15 @@
"type": "string",
"format": "datetime",
"description": "Timestamp when this label was created."
},
"exp": {
"type": "string",
"format": "datetime",
"description": "Timestamp at which this label expires (no longer applies)."
},
"sig": {
"type": "bytes",
"description": "Signature of dag-cbor encoded label."
}
}
},
Expand Down
14 changes: 14 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2202,6 +2202,10 @@ export const schemaDict = {
'Metadata tag on an atproto resource (eg, repo or record).',
required: ['src', 'uri', 'val', 'cts'],
properties: {
ver: {
type: 'integer',
description: 'The AT Protocol version of the label object.',
},
src: {
type: 'string',
format: 'did',
Expand Down Expand Up @@ -2235,6 +2239,16 @@ export const schemaDict = {
format: 'datetime',
description: 'Timestamp when this label was created.',
},
exp: {
type: 'string',
format: 'datetime',
description:
'Timestamp at which this label expires (no longer applies).',
},
sig: {
type: 'bytes',
description: 'Signature of dag-cbor encoded label.',
},
},
},
selfLabels: {
Expand Down
6 changes: 6 additions & 0 deletions packages/api/src/client/types/com/atproto/label/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { CID } from 'multiformats/cid'

/** Metadata tag on an atproto resource (eg, repo or record). */
export interface Label {
/** The AT Protocol version of the label object. */
ver?: number
/** DID of the actor who created this label. */
src: string
/** AT URI of the record, repository (account), or other resource that this label applies to. */
Expand All @@ -20,6 +22,10 @@ export interface Label {
neg?: boolean
/** Timestamp when this label was created. */
cts: string
/** Timestamp at which this label expires (no longer applies). */
exp?: string
/** Signature of dag-cbor encoded label. */
sig?: Uint8Array
[k: string]: unknown
}

Expand Down
9 changes: 6 additions & 3 deletions packages/bsky/src/api/app/bsky/actor/getProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { InvalidRequestError } from '@atproto/xrpc-server'
import { Server } from '../../../../lexicon'
import { QueryParams } from '../../../../lexicon/types/app/bsky/actor/getProfile'
import AppContext from '../../../../context'
import { setRepoRev } from '../../../util'
import { resHeaders } from '../../../util'
import { createPipeline, noRules } from '../../../../pipeline'
import {
HydrateCtx,
Expand All @@ -15,19 +15,22 @@ export default function (server: Server, ctx: AppContext) {
const getProfile = createPipeline(skeleton, hydration, noRules, presentation)
server.app.bsky.actor.getProfile({
auth: ctx.authVerifier.optionalStandardOrRole,
handler: async ({ auth, params, req, res }) => {
handler: async ({ auth, params, req }) => {
const { viewer, includeTakedowns } = ctx.authVerifier.parseCreds(auth)
const labelers = ctx.reqLabelers(req)
const hydrateCtx = { labelers, viewer, includeTakedowns }

const result = await getProfile({ ...params, hydrateCtx }, ctx)

const repoRev = await ctx.hydrator.actor.getRepoRevSafe(viewer)
setRepoRev(res, repoRev)

return {
encoding: 'application/json',
body: result,
headers: resHeaders({
repoRev,
labelers,
}),
}
},
})
Expand Down
9 changes: 6 additions & 3 deletions packages/bsky/src/api/app/bsky/actor/getProfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { mapDefined } from '@atproto/common'
import { Server } from '../../../../lexicon'
import { QueryParams } from '../../../../lexicon/types/app/bsky/actor/getProfiles'
import AppContext from '../../../../context'
import { setRepoRev } from '../../../util'
import { resHeaders } from '../../../util'
import { createPipeline, noRules } from '../../../../pipeline'
import {
HydrateCtx,
Expand All @@ -15,19 +15,22 @@ export default function (server: Server, ctx: AppContext) {
const getProfile = createPipeline(skeleton, hydration, noRules, presentation)
server.app.bsky.actor.getProfiles({
auth: ctx.authVerifier.standardOptional,
handler: async ({ auth, params, req, res }) => {
handler: async ({ auth, params, req }) => {
const viewer = auth.credentials.iss
const labelers = ctx.reqLabelers(req)
const hydrateCtx = { viewer, labelers }

const result = await getProfile({ ...params, hydrateCtx }, ctx)

const repoRev = await ctx.hydrator.actor.getRepoRevSafe(viewer)
setRepoRev(res, repoRev)

return {
encoding: 'application/json',
body: result,
headers: resHeaders({
repoRev,
labelers,
}),
}
},
})
Expand Down
2 changes: 2 additions & 0 deletions packages/bsky/src/api/app/bsky/actor/getSuggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { Views } from '../../../../views'
import { DataPlaneClient } from '../../../../data-plane'
import { parseString } from '../../../../hydration/util'
import { resHeaders } from '../../../util'

export default function (server: Server, ctx: AppContext) {
const getSuggestions = createPipeline(
Expand All @@ -30,6 +31,7 @@ export default function (server: Server, ctx: AppContext) {
return {
encoding: 'application/json',
body: result,
headers: resHeaders({ labelers }),
}
},
})
Expand Down
2 changes: 2 additions & 0 deletions packages/bsky/src/api/app/bsky/actor/searchActors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { HydrateCtx, Hydrator } from '../../../../hydration/hydrator'
import { Views } from '../../../../views'
import { DataPlaneClient } from '../../../../data-plane'
import { parseString } from '../../../../hydration/util'
import { resHeaders } from '../../../util'

export default function (server: Server, ctx: AppContext) {
const searchActors = createPipeline(
Expand All @@ -32,6 +33,7 @@ export default function (server: Server, ctx: AppContext) {
return {
encoding: 'application/json',
body: results,
headers: resHeaders({ labelers }),
}
},
})
Expand Down
2 changes: 2 additions & 0 deletions packages/bsky/src/api/app/bsky/actor/searchActorsTypeahead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { HydrateCtx, Hydrator } from '../../../../hydration/hydrator'
import { Views } from '../../../../views'
import { DataPlaneClient } from '../../../../data-plane'
import { parseString } from '../../../../hydration/util'
import { resHeaders } from '../../../util'

export default function (server: Server, ctx: AppContext) {
const searchActorsTypeahead = createPipeline(
Expand All @@ -35,6 +36,7 @@ export default function (server: Server, ctx: AppContext) {
return {
encoding: 'application/json',
body: results,
headers: resHeaders({ labelers }),
}
},
})
Expand Down
3 changes: 2 additions & 1 deletion packages/bsky/src/api/app/bsky/feed/getActorFeeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { Views } from '../../../../views'
import { DataPlaneClient } from '../../../../data-plane'
import { parseString } from '../../../../hydration/util'
import { clearlyBadCursor } from '../../../util'
import { clearlyBadCursor, resHeaders } from '../../../util'

export default function (server: Server, ctx: AppContext) {
const getActorFeeds = createPipeline(
Expand All @@ -31,6 +31,7 @@ export default function (server: Server, ctx: AppContext) {
return {
encoding: 'application/json',
body: result,
headers: resHeaders({ labelers }),
}
},
})
Expand Down
9 changes: 6 additions & 3 deletions packages/bsky/src/api/app/bsky/feed/getActorLikes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { mapDefined } from '@atproto/common'
import { Server } from '../../../../lexicon'
import { QueryParams } from '../../../../lexicon/types/app/bsky/feed/getActorLikes'
import AppContext from '../../../../context'
import { clearlyBadCursor, setRepoRev } from '../../../util'
import { clearlyBadCursor, resHeaders } from '../../../util'
import { createPipeline } from '../../../../pipeline'
import {
HydrateCtx,
Expand All @@ -25,19 +25,22 @@ export default function (server: Server, ctx: AppContext) {
)
server.app.bsky.feed.getActorLikes({
auth: ctx.authVerifier.standardOptional,
handler: async ({ params, auth, req, res }) => {
handler: async ({ params, auth, req }) => {
const viewer = auth.credentials.iss
const labelers = ctx.reqLabelers(req)
const hydrateCtx = { labelers, viewer }

const result = await getActorLikes({ ...params, hydrateCtx }, ctx)

const repoRev = await ctx.hydrator.actor.getRepoRevSafe(viewer)
setRepoRev(res, repoRev)

return {
encoding: 'application/json',
body: result,
headers: resHeaders({
repoRev,
labelers,
}),
}
},
})
Expand Down
9 changes: 6 additions & 3 deletions packages/bsky/src/api/app/bsky/feed/getAuthorFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { InvalidRequestError } from '@atproto/xrpc-server'
import { Server } from '../../../../lexicon'
import { QueryParams } from '../../../../lexicon/types/app/bsky/feed/getAuthorFeed'
import AppContext from '../../../../context'
import { clearlyBadCursor, setRepoRev } from '../../../util'
import { clearlyBadCursor, resHeaders } from '../../../util'
import { createPipeline } from '../../../../pipeline'
import {
HydrateCtx,
Expand All @@ -27,19 +27,22 @@ export default function (server: Server, ctx: AppContext) {
)
server.app.bsky.feed.getAuthorFeed({
auth: ctx.authVerifier.optionalStandardOrRole,
handler: async ({ params, auth, req, res }) => {
handler: async ({ params, auth, req }) => {
const { viewer, includeTakedowns } = ctx.authVerifier.parseCreds(auth)
const labelers = ctx.reqLabelers(req)
const hydrateCtx = { labelers, viewer, includeTakedowns }

const result = await getAuthorFeed({ ...params, hydrateCtx }, ctx)

const repoRev = await ctx.hydrator.actor.getRepoRevSafe(viewer)
setRepoRev(res, repoRev)

return {
encoding: 'application/json',
body: result,
headers: resHeaders({
repoRev,
labelers,
}),
}
},
})
Expand Down
14 changes: 9 additions & 5 deletions packages/bsky/src/api/app/bsky/feed/getFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
isDataplaneError,
unpackIdentityServices,
} from '../../../../data-plane'
import { resHeaders } from '../../../util'

export default function (server: Server, ctx: AppContext) {
const getFeed = createPipeline(
Expand All @@ -47,16 +48,19 @@ export default function (server: Server, ctx: AppContext) {
'accept-language': req.headers['accept-language'],
})
// @NOTE feed cursors should not be affected by appview swap
const { timerSkele, timerHydr, resHeaders, ...result } = await getFeed(
{ ...params, hydrateCtx, headers },
ctx,
)
const {
timerSkele,
timerHydr,
resHeaders: feedResHeaders,
...result
} = await getFeed({ ...params, hydrateCtx, headers }, ctx)

return {
encoding: 'application/json',
body: result,
headers: {
...(resHeaders ?? {}),
...(feedResHeaders ?? {}),
...resHeaders({ labelers }),
'server-timing': serverTimingHeader([timerSkele, timerHydr]),
},
}
Expand Down
2 changes: 2 additions & 0 deletions packages/bsky/src/api/app/bsky/feed/getFeedGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
isDataplaneError,
unpackIdentityServices,
} from '../../../../data-plane'
import { resHeaders } from '../../../util'

export default function (server: Server, ctx: AppContext) {
server.app.bsky.feed.getFeedGenerator({
Expand Down Expand Up @@ -63,6 +64,7 @@ export default function (server: Server, ctx: AppContext) {
isOnline: true,
isValid: true,
},
headers: resHeaders({ labelers }),
}
},
})
Expand Down
2 changes: 2 additions & 0 deletions packages/bsky/src/api/app/bsky/feed/getFeedGenerators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Hydrator,
} from '../../../../hydration/hydrator'
import { Views } from '../../../../views'
import { resHeaders } from '../../../util'

export default function (server: Server, ctx: AppContext) {
const getFeedGenerators = createPipeline(
Expand All @@ -27,6 +28,7 @@ export default function (server: Server, ctx: AppContext) {
return {
encoding: 'application/json',
body: view,
headers: resHeaders({ labelers }),
}
},
})
Expand Down
3 changes: 2 additions & 1 deletion packages/bsky/src/api/app/bsky/feed/getLikes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { Views } from '../../../../views'
import { parseString } from '../../../../hydration/util'
import { creatorFromUri } from '../../../../views/util'
import { clearlyBadCursor } from '../../../util'
import { clearlyBadCursor, resHeaders } from '../../../util'

export default function (server: Server, ctx: AppContext) {
const getLikes = createPipeline(skeleton, hydration, noBlocks, presentation)
Expand All @@ -27,6 +27,7 @@ export default function (server: Server, ctx: AppContext) {
return {
encoding: 'application/json',
body: result,
headers: resHeaders({ labelers }),
}
},
})
Expand Down
6 changes: 3 additions & 3 deletions packages/bsky/src/api/app/bsky/feed/getListFeed.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Server } from '../../../../lexicon'
import { QueryParams } from '../../../../lexicon/types/app/bsky/feed/getListFeed'
import AppContext from '../../../../context'
import { clearlyBadCursor, setRepoRev } from '../../../util'
import { clearlyBadCursor, resHeaders } from '../../../util'
import { createPipeline } from '../../../../pipeline'
import {
HydrateCtx,
Expand All @@ -23,19 +23,19 @@ export default function (server: Server, ctx: AppContext) {
)
server.app.bsky.feed.getListFeed({
auth: ctx.authVerifier.standardOptional,
handler: async ({ params, auth, req, res }) => {
handler: async ({ params, auth, req }) => {
const viewer = auth.credentials.iss
const labelers = ctx.reqLabelers(req)
const hydrateCtx = { labelers, viewer }

const result = await getListFeed({ ...params, hydrateCtx }, ctx)

const repoRev = await ctx.hydrator.actor.getRepoRevSafe(viewer)
setRepoRev(res, repoRev)

return {
encoding: 'application/json',
body: result,
headers: resHeaders({ labelers, repoRev }),
}
},
})
Expand Down
Loading

0 comments on commit 5fe83bf

Please sign in to comment.