fix: /houxu/lives/realtime fail when link.media == null (#1957)
This commit is contained in:
parent
d3704ce64c
commit
1fa670f132
|
|
@ -1,13 +1,16 @@
|
|||
const axios = require('../../utils/axios');
|
||||
|
||||
const liveUrlById = (liveId) => `https://houxu.app/lives/${liveId}`;
|
||||
const getLiveUrlById = (liveId) => `https://houxu.app/lives/${liveId}`;
|
||||
|
||||
const getLinkDesc = (link) => (link.media === null ? link.description : link.media.name + ':<br />' + link.description);
|
||||
|
||||
const realtimeHandler = async () => {
|
||||
const res = await axios.get('https://houxu.app/api/1/lives/updated/');
|
||||
|
||||
const out = res.data.results.map((el) => ({
|
||||
title: el.last.link.title,
|
||||
description: el.last.link.media.name + ':<br />' + el.last.link.description,
|
||||
link: liveUrlById(el.id),
|
||||
description: getLinkDesc(el.last.link),
|
||||
link: getLiveUrlById(el.id),
|
||||
guid: 'realtime-' + el.id + '-' + el.last.id,
|
||||
pubDate: new Date(el.last.create_at).toUTCString(),
|
||||
}));
|
||||
|
|
@ -27,7 +30,7 @@ const newHandler = async () => {
|
|||
.map((el) => ({
|
||||
title: el.object.title,
|
||||
description: el.object.summary,
|
||||
link: liveUrlById(el.id),
|
||||
link: getLiveUrlById(el.id),
|
||||
guid: 'new-' + el.id + '-' + el.object.id,
|
||||
pubDate: new Date(el.object.create_at).toUTCString(),
|
||||
}));
|
||||
|
|
|
|||
Loading…
Reference in New Issue