Fixed bug on removed cover
This commit is contained in:
parent
9203335963
commit
acc70e6a83
1 changed files with 12 additions and 3 deletions
15
libs.js
15
libs.js
|
@ -249,19 +249,28 @@ const formatMessage = (values) => {
|
|||
* @param {String} 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) {
|
||||
getMedia(cover, (err, dest) => {
|
||||
if (err) {
|
||||
M.post('statuses', { status: formatMessage(song) })
|
||||
M.post('statuses', { status }, catch)
|
||||
} else {
|
||||
M.post('media', { file: fs.createReadStream(dest) }).then(resp => {
|
||||
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 {
|
||||
M.post('statuses', { status: formatMessage(song) })
|
||||
M.post('statuses', { status }, catch)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue