diff --git a/services/appview/src/services/plugins/post.ts b/services/appview/src/services/plugins/post.ts --- a/services/appview/src/services/plugins/post.ts +++ b/services/appview/src/services/plugins/post.ts @@ -26,7 +26,6 @@ cid: CID, record: unknown, timestamp: string, - opts?: { disableNotifs?: boolean }, ) => Promise updateRecord: ( uri: AtUri, @@ -49,7 +48,6 @@ cid: CID, recordObj: unknown, timestamp: string, - opts = {}, ): Promise { const record = recordObj as PostRecord if (!record) return null @@ -121,6 +119,7 @@ // Update post data const postData = { + uri: uri.toString(), cid: cid.toString(), text: record.text, facets: record.facets || [], @@ -129,6 +128,7 @@ langs: record.langs || [], labels: record.labels || null, tags: record.tags || [], + authorDid: uri.hostname, authorHandle: actor.handle || uri.hostname, indexedAt: timestamp, } @@ -150,22 +150,26 @@ } }, - async deleteRecord(uri: AtUri): Promise { + async deleteRecord(uri: AtUri, cascading = false): Promise { try { + // Get the post to check author const post = await db.models.Post.findOne({ uri: uri.toString() }) - - if (post) { - // Delete the post - await db.models.Post.deleteOne({ uri: uri.toString() }) - - // Decrement post count for actor - await db.models.Actor.updateOne( - { did: uri.hostname }, - { $inc: { postsCount: -1 } } - ) - - // Delete any associated likes, reposts, etc. as needed - // This would be the cascading deletion logic + if (!post) { + logger.warn({ uri: uri.toString() }, 'Post not found for deletion') + return + } + + // Delete the post + await db.models.Post.deleteOne({ uri: uri.toString() }) + + // Decrement post count for author + await db.models.Actor.updateOne( + { did: post.authorDid }, + { $inc: { postsCount: -1 } } + ) + + if (cascading) { + // TODO: Handle cascading deletion (e.g. delete replies, reposts, etc.) } } catch (error) { logger.error( diff --git a/services/appview/src/routes/com/atproto/admin/getAccountInfos.ts b/services/appview/src/routes/com/atproto/admin/getAccountInfos.ts --- a/services/appview/src/routes/com/atproto/admin/getAccountInfos.ts +++ b/services/appview/src/routes/com/atproto/admin/getAccountInfos.ts @@ -9,7 +9,7 @@ import type * as ComAtprotoAdminDefs from '../../../../lexicon/types/com/atproto/admin/defs.js' import type * as ComAtprotoRepoStrongRef from '../../../../lexicon/types/com/atproto/repo/strongRef.js' -export const createGetAccountInfosRouter = (ctx: AppContext) => { +export const createGetAccountInfosRouter = (_ctx: AppContext) => { const router = new Hono() // XRPC endpoint for Ozone integration: com.atproto.admin.getAccountInfos @@ -23,7 +23,9 @@ }), ), async (c) => { - + const { dids } = c.req.valid('json') } ) + + return router }