fix(plugins/tweets): handle non text/html attachments
This commit is contained in:
@@ -50,6 +50,7 @@ export default async function({login, imports, data, q, account}, {enabled = fal
|
|||||||
if (tweet.attachments)
|
if (tweet.attachments)
|
||||||
tweet.attachments = await Promise.all(tweet.attachments.media_keys.filter(key => medias.get(key)).map(key => medias.get(key)).map(async url => ({image: await imports.imgb64(url, {height: -1, width: 450})})))
|
tweet.attachments = await Promise.all(tweet.attachments.media_keys.filter(key => medias.get(key)).map(key => medias.get(key)).map(async url => ({image: await imports.imgb64(url, {height: -1, width: 450})})))
|
||||||
if (linked) {
|
if (linked) {
|
||||||
|
try {
|
||||||
const {result: {ogImage, ogSiteName: website, ogTitle: title, ogDescription: description}} = await imports.opengraph({url: linked})
|
const {result: {ogImage, ogSiteName: website, ogTitle: title, ogDescription: description}} = await imports.opengraph({url: linked})
|
||||||
const image = await imports.imgb64(ogImage?.url, {height: -1, width: 450, fallback: false})
|
const image = await imports.imgb64(ogImage?.url, {height: -1, width: 450, fallback: false})
|
||||||
if (image) {
|
if (image) {
|
||||||
@@ -62,6 +63,10 @@ export default async function({login, imports, data, q, account}, {enabled = fal
|
|||||||
tweet.text = `${tweet.text}\n${linked}`
|
tweet.text = `${tweet.text}\n${linked}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.debug(`metrics/compute/${login}/plugins > tweets > error while retrieving linked content: ${error.message}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tweet.attachments = null
|
tweet.attachments = null
|
||||||
|
|||||||
Reference in New Issue
Block a user