fix(rssapi): flatten feedTitle, sourceTitle and author in item response

The /rssapi transformation was missing feedTitle, sourceTitle and author
fields that the /news page expects. Map them from the nested blog object.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sven
2026-03-17 09:21:23 +01:00
parent cb7b525368
commit fc9afa9bff

View File

@@ -42,21 +42,25 @@ const patchSpecs = [
// rssapi dual-mount alias: register the same public routes at /rssapi // rssapi dual-mount alias: register the same public routes at /rssapi
// with a response-shape transformer so the /news static page works. // with a response-shape transformer so the /news static page works.
// The /news page expects: item.link (not .url), item.feedId (not .blog.id), // The /news page expects: item.link (not .url), item.feedId (not .blog.id),
// item.sourceUrl (not .blog.siteUrl), and feedsRes.feeds (not .items). // item.feedTitle/sourceTitle (not .blog.title), item.sourceUrl (not .blog.siteUrl),
// item.author (fallback to .blog.title), and feedsRes.feeds (not .items).
const rssapiRouter = express.Router(); const rssapiRouter = express.Router();
rssapiRouter.use((req, res, next) => { rssapiRouter.use((req, res, next) => {
const originalJson = res.json.bind(res); const originalJson = res.json.bind(res);
res.json = function (data) { res.json = function (data) {
if (data && Array.isArray(data.items)) { if (data && Array.isArray(data.items)) {
if (req.path.startsWith("/api/items")) { if (req.path.startsWith("/api/items")) {
// Map url->link, blog.id->feedId, blog.siteUrl->sourceUrl // Map url->link, blog->flat feed fields
data = { data = {
...data, ...data,
items: data.items.map((item) => ({ items: data.items.map((item) => ({
...item, ...item,
link: item.url, link: item.url,
feedId: item.blog?.id ?? null, feedId: item.blog?.id ?? null,
feedTitle: item.blog?.title ?? null,
sourceUrl: item.blog?.siteUrl ?? null, sourceUrl: item.blog?.siteUrl ?? null,
sourceTitle: item.blog?.title ?? null,
author: item.author || item.blog?.title || null,
})), })),
}; };
} else if (req.path === "/api/feeds") { } else if (req.path === "/api/feeds") {