Skip to content

Commit

Permalink
clean up plc op submission
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Mar 12, 2024
1 parent 2802880 commit 2d4ac7a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/pds/src/api/com/atproto/identity/submitPlcOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import AppContext from '../../../../context'
import * as plc from '@did-plc/lib'
import { check } from '@atproto/common'
import { InvalidRequestError } from '@atproto/xrpc-server'
import { httpLogger as log } from '../../../../logger'

export default function (server: Server, ctx: AppContext) {
server.com.atproto.identity.submitPlcOperation({
Expand All @@ -15,7 +16,9 @@ export default function (server: Server, ctx: AppContext) {
throw new InvalidRequestError('Invalid operation')
}

if (!op.rotationKeys.includes(ctx.plcRotationKey.did())) {
const rotationKey =
ctx.cfg.entryway?.plcRotationKey ?? ctx.plcRotationKey.did()
if (!op.rotationKeys.includes(rotationKey)) {
throw new InvalidRequestError(
"Rotation keys do not include server's rotation key",
)
Expand Down Expand Up @@ -43,6 +46,15 @@ export default function (server: Server, ctx: AppContext) {
}

await ctx.plcClient.sendOperation(requester, op)
await ctx.sequencer.sequenceIdentityEvt(requester)
try {
await ctx.idResolver.did.resolve(requester, true)
} catch (err) {
log.error(
{ err, did: requester },
'failed to refresh did after plc update',
)
}
},
})
}

0 comments on commit 2d4ac7a

Please sign in to comment.