parent
a1bee406e2
commit
2d947be9c2
lexicons/app/bsky/actor
packages
api/src/client
pds
src
tests
@ -8,6 +8,7 @@
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"did": { "type": "string" },
|
||||
"displayName": {
|
||||
"type": "string",
|
||||
"maxLength": 64
|
||||
|
@ -1434,6 +1434,9 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
|
||||
schema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
did: {
|
||||
type: 'string',
|
||||
},
|
||||
displayName: {
|
||||
type: 'string',
|
||||
maxLength: 64,
|
||||
|
@ -12,6 +12,7 @@ export interface CallOptions {
|
||||
}
|
||||
|
||||
export interface InputSchema {
|
||||
did?: string;
|
||||
displayName?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
@ -18,19 +18,24 @@ export default function (server: Server) {
|
||||
if (!requester) {
|
||||
throw new AuthRequiredError()
|
||||
}
|
||||
const authStore = await locals.getAuthstore(res, requester)
|
||||
const uri = new AtUri(`${requester}/${profileNsid}/self`)
|
||||
const did = input.body.did || requester
|
||||
const authorized = await db.isUserControlledRepo(did, requester)
|
||||
if (!authorized) {
|
||||
throw new AuthRequiredError()
|
||||
}
|
||||
const authStore = await locals.getAuthstore(res, did)
|
||||
const uri = new AtUri(`${did}/${profileNsid}/self`)
|
||||
|
||||
const { profileCid, updated } = await db.transaction(
|
||||
async (dbTxn): Promise<{ profileCid: CID; updated: Profile.Record }> => {
|
||||
const currRoot = await dbTxn.getRepoRoot(requester, true)
|
||||
const currRoot = await dbTxn.getRepoRoot(did, true)
|
||||
if (!currRoot) {
|
||||
throw new InvalidRequestError(
|
||||
`${requester} is not a registered repo on this server`,
|
||||
`${did} is not a registered repo on this server`,
|
||||
)
|
||||
}
|
||||
const now = new Date().toISOString()
|
||||
const blockstore = new SqlBlockstore(dbTxn, requester, now)
|
||||
const blockstore = new SqlBlockstore(dbTxn, did, now)
|
||||
const repo = await RepoStructure.load(blockstore, currRoot)
|
||||
const current = await repo.getRecord(profileNsid, 'self')
|
||||
if (!db.records.profile.matchesSchema(current)) {
|
||||
@ -78,9 +83,9 @@ export default function (server: Server) {
|
||||
cid: profileCid,
|
||||
})
|
||||
.createCommit(authStore, async (prev, curr) => {
|
||||
const success = await dbTxn.updateRepoRoot(requester, curr, prev)
|
||||
const success = await dbTxn.updateRepoRoot(did, curr, prev)
|
||||
if (!success) {
|
||||
logger.error({ did: requester, curr, prev }, 'repo update failed')
|
||||
logger.error({ did, curr, prev }, 'repo update failed')
|
||||
throw new Error('Could not update repo root')
|
||||
}
|
||||
return null
|
||||
|
@ -1434,6 +1434,9 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
|
||||
schema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
did: {
|
||||
type: 'string',
|
||||
},
|
||||
displayName: {
|
||||
type: 'string',
|
||||
maxLength: 64,
|
||||
|
@ -11,6 +11,7 @@ export interface HandlerInput {
|
||||
}
|
||||
|
||||
export interface InputSchema {
|
||||
did?: string;
|
||||
displayName?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
@ -131,11 +131,16 @@ export class SeedClient {
|
||||
return this.accounts[shortName]
|
||||
}
|
||||
|
||||
async createProfile(by: string, displayName: string, description: string) {
|
||||
async createProfile(
|
||||
by: string,
|
||||
displayName: string,
|
||||
description: string,
|
||||
fromUser?: string,
|
||||
) {
|
||||
const res = await this.client.app.bsky.actor.profile.create(
|
||||
{ did: by },
|
||||
{ displayName, description },
|
||||
this.getHeaders(by),
|
||||
this.getHeaders(fromUser || by),
|
||||
)
|
||||
this.profiles[by] = {
|
||||
displayName,
|
||||
|
@ -7,7 +7,8 @@ export default async (sc: SeedClient) => {
|
||||
const carol = sc.dids.carol
|
||||
const dan = sc.dids.dan
|
||||
|
||||
await sc.createScene(bob, 'scene.test')
|
||||
const scene = await sc.createScene(bob, 'scene.test')
|
||||
await sc.createProfile(scene.did, 'besties', 'best friends eva', bob)
|
||||
await sc.inviteToScene('scene.test', sc.actorRef(alice))
|
||||
await sc.inviteToScene('scene.test', sc.actorRef(carol))
|
||||
await sc.inviteToScene('scene.test', sc.actorRef(dan))
|
||||
|
@ -426,6 +426,7 @@ Array [
|
||||
"cid": "cids(2)",
|
||||
},
|
||||
"did": "user(1)",
|
||||
"displayName": "besties",
|
||||
"handle": "scene.test",
|
||||
},
|
||||
"upvoteCount": 2,
|
||||
@ -460,6 +461,7 @@ Array [
|
||||
"cid": "cids(2)",
|
||||
},
|
||||
"did": "user(1)",
|
||||
"displayName": "besties",
|
||||
"handle": "scene.test",
|
||||
},
|
||||
"upvoteCount": 2,
|
||||
|
@ -53,6 +53,7 @@ Object {
|
||||
"cid": "cids(0)",
|
||||
},
|
||||
"did": "user(0)",
|
||||
"displayName": "besties",
|
||||
"handle": "scene.test",
|
||||
},
|
||||
}
|
||||
@ -163,6 +164,7 @@ Object {
|
||||
"cid": "cids(1)",
|
||||
},
|
||||
"did": "user(3)",
|
||||
"displayName": "besties",
|
||||
"handle": "scene.test",
|
||||
"indexedAt": "1970-01-01T00:00:00.000Z",
|
||||
},
|
||||
@ -200,6 +202,7 @@ Object {
|
||||
"cid": "cids(1)",
|
||||
},
|
||||
"did": "user(2)",
|
||||
"displayName": "besties",
|
||||
"handle": "scene.test",
|
||||
"indexedAt": "1970-01-01T00:00:00.000Z",
|
||||
},
|
||||
@ -237,6 +240,7 @@ Object {
|
||||
"cid": "cids(1)",
|
||||
},
|
||||
"did": "user(2)",
|
||||
"displayName": "besties",
|
||||
"handle": "scene.test",
|
||||
"indexedAt": "1970-01-01T00:00:00.000Z",
|
||||
},
|
||||
@ -273,6 +277,7 @@ Object {
|
||||
"cid": "cids(1)",
|
||||
},
|
||||
"did": "user(2)",
|
||||
"displayName": "besties",
|
||||
"handle": "scene.test",
|
||||
"indexedAt": "1970-01-01T00:00:00.000Z",
|
||||
},
|
||||
|
@ -96,6 +96,7 @@ Array [
|
||||
"cid": "cids(6)",
|
||||
},
|
||||
"did": "user(3)",
|
||||
"displayName": "besties",
|
||||
"handle": "scene.test",
|
||||
},
|
||||
"cid": "cids(5)",
|
||||
@ -373,6 +374,7 @@ Array [
|
||||
"cid": "cids(6)",
|
||||
},
|
||||
"did": "user(3)",
|
||||
"displayName": "besties",
|
||||
"handle": "scene.test",
|
||||
},
|
||||
"cid": "cids(18)",
|
||||
@ -490,6 +492,7 @@ Array [
|
||||
"cid": "cids(6)",
|
||||
},
|
||||
"did": "user(3)",
|
||||
"displayName": "besties",
|
||||
"handle": "scene.test",
|
||||
},
|
||||
"cid": "cids(5)",
|
||||
@ -767,6 +770,7 @@ Array [
|
||||
"cid": "cids(6)",
|
||||
},
|
||||
"did": "user(3)",
|
||||
"displayName": "besties",
|
||||
"handle": "scene.test",
|
||||
},
|
||||
"cid": "cids(18)",
|
||||
|
@ -64,7 +64,9 @@ Object {
|
||||
"actorType": "app.bsky.system.actorScene",
|
||||
"cid": "cids(0)",
|
||||
},
|
||||
"description": "best friends eva",
|
||||
"did": "user(0)",
|
||||
"displayName": "besties",
|
||||
"followersCount": 0,
|
||||
"followsCount": 0,
|
||||
"handle": "scene.test",
|
||||
@ -95,6 +97,27 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`pds profile views handles scene profile updates 1`] = `
|
||||
Object {
|
||||
"creator": "user(1)",
|
||||
"declaration": Object {
|
||||
"actorType": "app.bsky.system.actorScene",
|
||||
"cid": "cids(0)",
|
||||
},
|
||||
"description": "feeling scene",
|
||||
"did": "user(0)",
|
||||
"displayName": "besties",
|
||||
"followersCount": 0,
|
||||
"followsCount": 0,
|
||||
"handle": "scene.test",
|
||||
"membersCount": 4,
|
||||
"myState": Object {
|
||||
"member": "record(0)",
|
||||
},
|
||||
"postsCount": 0,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`pds profile views updates profile 1`] = `
|
||||
Object {
|
||||
"creator": "user(0)",
|
||||
|
@ -204,6 +204,7 @@ Array [
|
||||
"cid": "cids(7)",
|
||||
},
|
||||
"did": "user(4)",
|
||||
"displayName": "besties",
|
||||
"handle": "scene.test",
|
||||
},
|
||||
"upvoteCount": 2,
|
||||
@ -236,6 +237,7 @@ Array [
|
||||
"cid": "cids(7)",
|
||||
},
|
||||
"did": "user(4)",
|
||||
"displayName": "besties",
|
||||
"handle": "scene.test",
|
||||
},
|
||||
"upvoteCount": 2,
|
||||
@ -608,6 +610,7 @@ Array [
|
||||
"cid": "cids(6)",
|
||||
},
|
||||
"did": "user(4)",
|
||||
"displayName": "besties",
|
||||
"handle": "scene.test",
|
||||
},
|
||||
"upvoteCount": 2,
|
||||
@ -642,6 +645,7 @@ Array [
|
||||
"cid": "cids(6)",
|
||||
},
|
||||
"did": "user(4)",
|
||||
"displayName": "besties",
|
||||
"handle": "scene.test",
|
||||
},
|
||||
"upvoteCount": 2,
|
||||
|
@ -98,6 +98,22 @@ describe('pds profile views', () => {
|
||||
expect(forSnapshot(aliceForAlice.data)).toMatchSnapshot()
|
||||
})
|
||||
|
||||
it('handles scene profile updates', async () => {
|
||||
await client.app.bsky.actor.updateProfile(
|
||||
{ did: scene, displayName: 'besties', description: 'feeling scene' },
|
||||
{ headers: sc.getHeaders(bob), encoding: 'application/json' },
|
||||
)
|
||||
|
||||
const sceneForAlice = await client.app.bsky.actor.getProfile(
|
||||
{ actor: scene },
|
||||
{ headers: sc.getHeaders(alice) },
|
||||
)
|
||||
|
||||
expect(forSnapshot(sceneForAlice.data)).toMatchSnapshot()
|
||||
})
|
||||
|
||||
return
|
||||
|
||||
it('handles racing updates', async () => {
|
||||
const descriptions: string[] = []
|
||||
const COUNT = 10
|
||||
|
Loading…
x
Reference in New Issue
Block a user