Browse Source

Prevent crash

main
Yarmo Mackenbach 1 month ago
parent
commit
757b7e1af9
1 changed files with 15 additions and 10 deletions
  1. 25
      server/util.js

25
server/util.js

@ -120,16 +120,21 @@ const getPost = async (slug) => {
}
const getWebmentions = async (url) => {
const data_1 = await getJSON(`https://webm.yarmo.eu/get?target=${url}`)
const data_2 = await getJSON(`https://webm.yarmo.eu/get?target=${url.replace('/post/', '/blog/')}`)
const data_3 = await getJSON(`https://webm.yarmo.eu/get?target=${url.replace('/post/', '/notes/')}`)
const dataRaw = data_1.concat(data_2).concat(data_3)
const data = _.map(dataRaw, (x) => {
x.date = DateTime.fromISO(x.created_at).setLocale("en").setZone('utc').toLocaleString(DateTime.DATE_MED),
x.time = DateTime.fromISO(x.created_at).setLocale("en").setZone('utc').toLocaleString(DateTime.TIME_24_WITH_SHORT_OFFSET)
return x
})
let data
try {
const data_1 = await getJSON(`https://webm.yarmo.eu/get?target=${url}`)
const data_2 = await getJSON(`https://webm.yarmo.eu/get?target=${url.replace('/post/', '/blog/')}`)
const data_3 = await getJSON(`https://webm.yarmo.eu/get?target=${url.replace('/post/', '/notes/')}`)
const dataRaw = data_1.concat(data_2).concat(data_3)
data = _.map(dataRaw, (x) => {
x.date = DateTime.fromISO(x.created_at).setLocale("en").setZone('utc').toLocaleString(DateTime.DATE_MED),
x.time = DateTime.fromISO(x.created_at).setLocale("en").setZone('utc').toLocaleString(DateTime.TIME_24_WITH_SHORT_OFFSET)
return x
})
} catch(e) {
data = []
}
return data
}

Loading…
Cancel
Save