Fixed bug on removed cover

This commit is contained in:
dbroqua 2020-05-01 09:10:13 +02:00
parent 9203335963
commit acc70e6a83

15
libs.js
View file

@ -249,19 +249,28 @@ const formatMessage = (values) => {
* @param {String} cover * @param {String} cover
*/ */
const publishMessage = (song, cover) => { const publishMessage = (song, cover) => {
const status = formatMessage(song)
const catch = (err, res) => {
if ( err ) {
console.log(config.colors.FgRed, 'ERR on publishMessage:', err, config.colors.Reset)
}
}
if (cover) { if (cover) {
getMedia(cover, (err, dest) => { getMedia(cover, (err, dest) => {
if (err) { if (err) {
M.post('statuses', { status: formatMessage(song) }) M.post('statuses', { status }, catch)
} else { } else {
M.post('media', { file: fs.createReadStream(dest) }).then(resp => { M.post('media', { file: fs.createReadStream(dest) }).then(resp => {
const id = resp.data.id const id = resp.data.id
M.post('statuses', { status: formatMessage(song), media_ids: [id] }) M.post('statuses', { status, media_ids: [id] }, catch)
})
.catch( () => {
M.post('statuses', { status }, catch)
}) })
} }
}) })
} else { } else {
M.post('statuses', { status: formatMessage(song) }) M.post('statuses', { status }, catch)
} }
} }