From 784f2c526ff34db5e58d8d008334258ab9e2b6d4 Mon Sep 17 00:00:00 2001 From: cooder Date: Thu, 14 Mar 2024 10:56:34 +0800 Subject: [PATCH] feat: add author for all feeds close #75 --- apps/server/src/feeds/feeds.service.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/server/src/feeds/feeds.service.ts b/apps/server/src/feeds/feeds.service.ts index 29a08f9..7fad496 100644 --- a/apps/server/src/feeds/feeds.service.ts +++ b/apps/server/src/feeds/feeds.service.ts @@ -156,6 +156,7 @@ export class FeedsService { copyright: '', updated: new Date(feedInfo.updateTime * 1e3), generator: 'WeWe-RSS', + author: { name: feedInfo.mpName }, }); feed.addExtension({ @@ -163,16 +164,23 @@ export class FeedsService { objects: `WeWe-RSS`, }); + const feeds = await this.prismaService.feed.findMany({ + select: { id: true, mpName: true }, + }); + /**mode 高于 globalMode。如果 mode 值存在,取 mode 值*/ const enableFullText = typeof mode === 'string' ? mode === 'fulltext' : globalMode === 'fulltext'; + const showAuthor = feedInfo.id === 'all'; + const mapper = async (item) => { - const { title, id, publishTime, picUrl } = item; + const { title, id, publishTime, picUrl, mpId } = item; const link = `https://mp.weixin.qq.com/s/${id}`; + const mpName = feeds.find((item) => item.id === mpId)?.mpName || '-'; const published = new Date(publishTime * 1e3); let description = ''; @@ -188,6 +196,7 @@ export class FeedsService { description, date: published, image: picUrl, + author: showAuthor ? [{ name: mpName }] : undefined, }); };