From a7b20283ec91369e71bff42ced9df59c2bfd074f Mon Sep 17 00:00:00 2001 From: Derek Date: Sun, 13 May 2018 22:51:22 +0800 Subject: [PATCH] fix #109 (#111) * fix(jike user): shorten title and add repost content * fix #109 --- routes/jike/user.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/routes/jike/user.js b/routes/jike/user.js index 9865ffca2..ecd2f226b 100644 --- a/routes/jike/user.js +++ b/routes/jike/user.js @@ -9,7 +9,7 @@ module.exports = async (ctx) => { url: 'https://app.jike.ruguoapp.com/1.0/personalUpdate/single', headers: { 'User-Agent': config.ua, - 'Referer': `https://web.okjike.com/user/${id}`, + 'Referer': `https://web.okjike.com/user/${id}/post`, 'App-Version': '4.1.0', 'platform': 'web' }, @@ -42,13 +42,30 @@ module.exports = async (ctx) => { imgTemplate += `
`; }); - const content = item.content || item.linkInfo && item.linkInfo.title || item.target && item.target.content; + let content = item.content || item.linkInfo && item.linkInfo.title || item.target && item.target.content; + const shortenTitle = content.length > 75 ? `${content.substr(0, 75)}...` : content; + + if (item.type === 'REPOST') { + const targetLinkMap = { + 'OFFICIAL_MESSAGE': `https://web.okjike.com/message-detail/${item.target.id}/officialMessage`, + 'ORIGINAL_POST': `https://web.okjike.com/post-detail/${item.target.id}/originalPost`, + 'REPOST': `https://web.okjike.com/post-detail/${item.target.id}/repost` + }; + let repostImgTemplate = ''; + item.target.pictures && item.target.pictures.forEach((item) => { + repostImgTemplate += `

`; + }); + + let repostContent = `

@${item.target.user.screenName}

${item.target.content}${repostImgTemplate}
`; + content = `${content}${repostContent}`; + } + return { - title: `${typeMap[item.type]}了: ${content}`, + title: `${typeMap[item.type]}了: ${shortenTitle}`, description: `${content}${linkTemplate}${imgTemplate}`, pubDate: new Date(item.createdAt).toUTCString(), - link: `https://web.okjike.com/message-detail/${item.id}/officialMessage` + link: `https://web.okjike.com/post-detail/${item.id}/originalPost` } }), }; -}; \ No newline at end of file +};