feat(life): add Life Post detail page and endpoint

Implement GET /api/life-posts/:id with moderation and visibility rules
Add /life/:id route and LifePostDetail view
Update feeds and user profiles to link to the new detail page
This commit is contained in:
2026-05-04 09:51:31 +08:00
parent bcff83a512
commit 7ff7e18b94
10 changed files with 1039 additions and 10 deletions

View File

@@ -68,6 +68,7 @@ import {
getAncientArtifact,
getHabitat,
getItem,
getLifePost,
getOptions,
getPokemon,
getPublicUserProfile,
@@ -1198,6 +1199,16 @@ app.get('/api/life-posts', async (request) => {
);
});
app.get('/api/life-posts/:id', async (request, reply) => {
const { id } = request.params as { id: string };
const user = await optionalUser(request);
const canViewAll = user
? userHasPermission(user, 'life.posts.update-any') || userHasPermission(user, 'life.posts.delete-any')
: false;
const post = await getLifePost(Number(id), user?.id ?? null, requestLocale(request), canViewAll);
return post ? post : notFound(reply, request);
});
app.get('/api/life-posts/:postId/comments', async (request, reply) => {
const { postId } = request.params as { postId: string };
const user = await optionalUser(request);