+22
-1
packages/appview/src/lib/hydrate.ts
+22
-1
packages/appview/src/lib/hydrate.ts
···
1
-
import { XyzStatusphereDefs } from '@statusphere/lexicon'
1
+
import {
2
+
AppBskyActorDefs,
3
+
AppBskyActorProfile,
4
+
XyzStatusphereDefs,
5
+
} from '@statusphere/lexicon'
2
6
3
7
import { Status } from '#/db'
4
8
import { AppContext } from '#/index'
···
19
23
},
20
24
}
21
25
}
26
+
27
+
export async function bskyProfileToProfileView(
28
+
did: string,
29
+
profile: AppBskyActorProfile.Record,
30
+
ctx: AppContext,
31
+
): Promise<AppBskyActorDefs.ProfileView> {
32
+
return {
33
+
$type: 'app.bsky.actor.defs#profileView',
34
+
did: did,
35
+
handle: await ctx.resolver.resolveDidToHandle(did),
36
+
avatar: profile.avatar
37
+
? `https://atproto.pictures/img/${did}/${profile.avatar.ref}`
38
+
: undefined,
39
+
displayName: profile.displayName,
40
+
createdAt: profile.createdAt,
41
+
}
42
+
}
+2
-13
packages/appview/src/routes.ts
+2
-13
packages/appview/src/routes.ts
···
13
13
14
14
import type { AppContext } from '#/index'
15
15
import { env } from '#/lib/env'
16
-
import { statusToStatusView } from '#/lib/hydrate'
16
+
import { bskyProfileToProfileView, statusToStatusView } from '#/lib/hydrate'
17
17
18
18
type Session = { did: string }
19
19
···
222
222
}
223
223
}
224
224
225
-
const profileView: AppBskyActorDefs.ProfileView = {
226
-
$type: 'app.bsky.actor.defs#profileView',
227
-
did: did,
228
-
handle: await ctx.resolver.resolveDidToHandle(did),
229
-
avatar: profile.avatar
230
-
? `https://atproto.pictures/img/${did}/${profile.avatar.ref}`
231
-
: undefined,
232
-
displayName: profile.displayName,
233
-
createdAt: profile.createdAt,
234
-
}
235
-
236
225
// Fetch user status
237
226
const status = await ctx.db
238
227
.selectFrom('status')
···
243
232
244
233
res.json({
245
234
did: agent.assertDid,
246
-
profile: profileView,
235
+
profile: await bskyProfileToProfileView(did, profile, ctx),
247
236
status: status ? await statusToStatusView(status, ctx) : undefined,
248
237
})
249
238
} catch (err) {