fix(route/twitter): undefined username and author in feeds
This commit is contained in:
parent
5048710a37
commit
4cf510d2d7
|
|
@ -82,9 +82,13 @@ async function handler(ctx) {
|
|||
description: userInfo?.description,
|
||||
item:
|
||||
data &&
|
||||
utils.ProcessFeed(ctx, {
|
||||
data,
|
||||
}),
|
||||
utils.ProcessFeed(
|
||||
ctx,
|
||||
{
|
||||
data,
|
||||
},
|
||||
{ userScreenName: userInfo?.screen_name, userName: userInfo?.name }
|
||||
),
|
||||
allowEmpty: true,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
|||
sizeOfAuthorAvatar: fallback(params.sizeOfAuthorAvatar, queryToInteger(routeParams.get('sizeOfAuthorAvatar')), 48),
|
||||
sizeOfQuotedAuthorAvatar: fallback(params.sizeOfQuotedAuthorAvatar, queryToInteger(routeParams.get('sizeOfQuotedAuthorAvatar')), 24),
|
||||
mediaNumber: fallback(params.mediaNumber, queryToInteger(routeParams.get('mediaNumber')), false),
|
||||
userScreenName: params.userScreenName,
|
||||
userName: params.userName,
|
||||
};
|
||||
|
||||
params = mergedParams;
|
||||
|
|
@ -91,6 +93,8 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
|||
heightOfPics,
|
||||
sizeOfAuthorAvatar,
|
||||
sizeOfQuotedAuthorAvatar,
|
||||
userScreenName,
|
||||
userName,
|
||||
} = params;
|
||||
|
||||
const formatVideo = (media, extraAttrs = '') => {
|
||||
|
|
@ -280,7 +284,7 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
|||
// Make title
|
||||
let title = '';
|
||||
if (showAuthorInTitle) {
|
||||
title += originalItem.user.name + ': ';
|
||||
title += userName + ': ';
|
||||
}
|
||||
const isRetweet = originalItem !== item;
|
||||
const isQuote = item.is_quote_status;
|
||||
|
|
@ -304,7 +308,7 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
|||
}
|
||||
|
||||
if (showAuthorAsTitleOnly) {
|
||||
title = originalItem.user.name;
|
||||
title = userName;
|
||||
}
|
||||
|
||||
// Make description
|
||||
|
|
@ -316,12 +320,12 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
|||
if (showAuthorInDesc) {
|
||||
if (readable) {
|
||||
description += '<small>';
|
||||
description += `<a href='https://x.com/${originalItem.user.screen_name}' target='_blank' rel='noopener noreferrer'>`;
|
||||
description += `<a href='https://x.com/${userScreenName}' target='_blank' rel='noopener noreferrer'>`;
|
||||
}
|
||||
if (authorNameBold) {
|
||||
description += `<strong>`;
|
||||
}
|
||||
description += originalItem.user.name;
|
||||
description += userName;
|
||||
if (authorNameBold) {
|
||||
description += `</strong>`;
|
||||
}
|
||||
|
|
@ -334,12 +338,12 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
|||
if (!showAuthorInDesc) {
|
||||
description += ' ';
|
||||
if (readable) {
|
||||
description += `<a href='https://x.com/${item.user.screen_name}' target='_blank' rel='noopener noreferrer'>`;
|
||||
description += `<a href='https://x.com/${item.user?.screen_name || userScreenName}' target='_blank' rel='noopener noreferrer'>`;
|
||||
}
|
||||
if (authorNameBold) {
|
||||
description += `<strong>`;
|
||||
}
|
||||
description += item.user.name;
|
||||
description += item.user?.name || userName;
|
||||
if (authorNameBold) {
|
||||
description += `</strong>`;
|
||||
}
|
||||
|
|
@ -354,7 +358,7 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
|||
}
|
||||
if (showAuthorInDesc) {
|
||||
if (readable) {
|
||||
description += `<a href='https://x.com/${item.user.screen_name}' target='_blank' rel='noopener noreferrer'>`;
|
||||
description += `<a href='https://x.com/${item.user?.screen_name || userScreenName}' target='_blank' rel='noopener noreferrer'>`;
|
||||
}
|
||||
|
||||
if (showAuthorAvatarInDesc) {
|
||||
|
|
@ -363,7 +367,7 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
|||
if (authorNameBold) {
|
||||
description += `<strong>`;
|
||||
}
|
||||
description += item.user.name;
|
||||
description += item.user?.name || userName;
|
||||
if (authorNameBold) {
|
||||
description += `</strong>`;
|
||||
}
|
||||
|
|
@ -393,16 +397,16 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
|||
}
|
||||
|
||||
const link =
|
||||
originalItem.user.screen_name && (originalItem.id_str || originalItem.conversation_id_str)
|
||||
? `https://x.com/${originalItem.user.screen_name}/status/${originalItem.id_str || originalItem.conversation_id_str}`
|
||||
: `https://x.com/${item.user.screen_name}/status/${item.id_str || item.conversation_id_str}`;
|
||||
userScreenName && (originalItem.id_str || originalItem.conversation_id_str)
|
||||
? `https://x.com/${userScreenName}/status/${originalItem.id_str || originalItem.conversation_id_str}`
|
||||
: `https://x.com/${item.user?.screen_name || userScreenName}/status/${item.id_str || item.conversation_id_str}`;
|
||||
return {
|
||||
title,
|
||||
author: [
|
||||
{
|
||||
name: originalItem.user.name,
|
||||
url: `https://x.com/${originalItem.user.screen_name}`,
|
||||
avatar: originalItem.user.profile_image_url_https,
|
||||
name: userName,
|
||||
url: `https://x.com/${userScreenName}`,
|
||||
avatar: originalItem.user?.profile_image_url_https,
|
||||
},
|
||||
],
|
||||
description,
|
||||
|
|
@ -414,7 +418,7 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
|||
(isRetweet && {
|
||||
links: [
|
||||
{
|
||||
url: `https://x.com/${item.user?.screen_name}/status/${item.conversation_id_str}`,
|
||||
url: `https://x.com/${item.user?.screen_name || userScreenName}/status/${item.conversation_id_str}`,
|
||||
type: 'repost',
|
||||
},
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in New Issue