Show the liked post in notifications with text or media preview

Hop-State: A_06FPB5RGJ37K5NPB79MT66G
Hop-Proposal: R_06FPB5QJB3W279N6JSGB8R0
Hop-Task: T_06FPB4PW583MAWM13VA1VT8
Hop-Attempt: AT_06FPB4PW5A561YFQGJBWW1G
This commit is contained in:
2026-07-15 04:43:46 -07:00
committed by Hop
parent 93be1cffd8
commit c1f3afa103
4 changed files with 144 additions and 9 deletions
+17 -3
View File
@@ -1,7 +1,7 @@
import { NextResponse } from 'next/server';
import { db, notifications } from '@/db';
import { requireAuth } from '@/lib/auth';
import { and, desc, eq, inArray, isNull } from 'drizzle-orm';
import { and, eq, inArray } from 'drizzle-orm';
import { z } from 'zod';
const markSchema = z.object({
@@ -52,6 +52,14 @@ export async function GET(request: Request) {
},
orderBy: (notifications, { desc }) => [desc(notifications.createdAt)],
limit,
with: {
post: {
with: {
author: true,
media: true,
},
},
},
});
// For remote actors missing avatar, fetch fresh data
@@ -108,8 +116,14 @@ export async function GET(request: Request) {
} : null,
post: row.postId ? {
id: row.postId,
content: row.postContent,
authorHandle: row.actorHandle, // The actor is the post author for likes/reposts
content: row.post?.content || row.postContent,
authorHandle: row.post?.author?.handle || null,
media: row.post?.media.map((item) => ({
url: item.url,
mimeType: item.mimeType,
altText: item.altText,
})) || [],
linkPreviewImage: row.post?.linkPreviewImage || null,
} : null,
};
});