@@ -2,7 +2,6 @@ import { db } from "@/lib/db";
22import * as schema from "@/lib/schema" ;
33import { atprotoGetRecord } from "@/lib/data/atproto/record" ;
44import { Commit } from "@/lib/data/atproto/event" ;
5- import * as atprotoPost from "@/lib/data/atproto/post" ;
65import * as dbPost from "@/lib/data/db/post" ;
76import * as atprotoComment from "@/lib/data/atproto/comment" ;
87import { VoteRecord } from "@/lib/data/atproto/vote" ;
@@ -17,6 +16,7 @@ import {
1716 unauthed_createCommentVote ,
1817} from "@/lib/data/db/vote" ;
1918import { unauthed_createNotification } from "@/lib/data/db/notification" ;
19+ import { atprotoClient , nsids } from "@/lib/data/atproto/repo" ;
2020
2121export async function POST ( request : Request ) {
2222 const auth = request . headers . get ( "Authorization" ) ;
@@ -36,24 +36,23 @@ export async function POST(request: Request) {
3636 throw new Error ( "No AtprotoPersonalDataServer service found" ) ;
3737 }
3838
39+ const atproto = atprotoClient ( service ) ;
40+
3941 const promises = ops . map ( async ( op ) => {
4042 const { collection, rkey } = op . path ;
4143 console . log ( "Processing" , collection , rkey , op . action ) ;
4244
43- if ( collection === atprotoPost . PostCollection ) {
45+ if ( collection === nsids . FyiUnravelFrontpagePost ) {
4446 if ( op . action === "create" ) {
45- const record = await atprotoGetRecord ( {
46- serviceEndpoint : service ,
47+ const postRecord = await atproto . fyi . unravel . frontpage . post . get ( {
4748 repo,
48- collection,
4949 rkey,
5050 } ) ;
51- const postRecord = atprotoPost . PostRecord . parse ( record . value ) ;
5251 await dbPost . unauthed_createPost ( {
53- post : postRecord ,
52+ post : postRecord . value ,
5453 rkey,
5554 authorDid : repo ,
56- cid : record . cid ,
55+ cid : postRecord . cid ,
5756 offset : seq ,
5857 } ) ;
5958 } else if ( op . action === "delete" ) {
@@ -108,7 +107,7 @@ export async function POST(request: Request) {
108107
109108 if (
110109 hydratedVoteRecordValue . subject . uri . collection ===
111- atprotoPost . PostCollection
110+ nsids . FyiUnravelFrontpagePost
112111 ) {
113112 await unauthed_createPostVote ( {
114113 repo,
0 commit comments