Testing implementation for private data in ATProto with ATPKeyserver and ATCute tools
1import { db } from '@api/db/db'
2import type { Did } from '@atcute/lexicons'
3import type { AppWafrnContentPrivatePost } from '@watproto/lexicon'
4
5/**
6 * Cache a private post in the database
7 */
8export default async function cachePrivatePost(
9 uri: string,
10 authorDid: Did,
11 record: AppWafrnContentPrivatePost.Main
12) {
13 const row = await db
14 .insertInto('private_posts')
15 .values({
16 author_did: authorDid,
17 uri,
18 encrypted_content: record.encryptedContent,
19 key_version: record.keyVersion,
20 created_at: new Date(record.createdAt).getTime(),
21 visibility: record.visibility
22 })
23 .returning(['indexed_at'])
24 .executeTakeFirstOrThrow()
25
26 return new Date(row.indexed_at).toISOString()
27}