|
|
@ -14,7 +14,7 @@ try {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
// eslint-disable-next-line
|
|
|
|
// eslint-disable-next-line
|
|
|
|
console.warn(e.message);
|
|
|
|
console.warn(e.message)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const extractMediaId = morph.get('data.media_id_string')
|
|
|
|
const extractMediaId = morph.get('data.media_id_string')
|
|
|
|
const extractImageUrl = morph.get('data.entities.media.0.display_url')
|
|
|
|
const extractImageUrl = morph.get('data.entities.media.0.display_url')
|
|
|
@ -22,10 +22,10 @@ const extractErrorCode = morph.get('0.code')
|
|
|
|
|
|
|
|
|
|
|
|
const uploadImage = data => client.post('media/upload', { media_data: data })
|
|
|
|
const uploadImage = data => client.post('media/upload', { media_data: data })
|
|
|
|
const uploadMetadata = (altText, twitterRes = {}) => {
|
|
|
|
const uploadMetadata = (altText, twitterRes = {}) => {
|
|
|
|
if (!altText)
|
|
|
|
if (!altText) return twitterRes
|
|
|
|
return twitterRes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const formattedAltText = altText.length > MAX_ALT_TEXT_LENGTH
|
|
|
|
const formattedAltText =
|
|
|
|
|
|
|
|
altText.length > MAX_ALT_TEXT_LENGTH
|
|
|
|
? `${altText.slice(0, MAX_ALT_TEXT_LENGTH - 3)}...`
|
|
|
|
? `${altText.slice(0, MAX_ALT_TEXT_LENGTH - 3)}...`
|
|
|
|
: altText
|
|
|
|
: altText
|
|
|
|
|
|
|
|
|
|
|
@ -36,10 +36,11 @@ const uploadMetadata = (altText, twitterRes = {}) => {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then(() => twitterRes)
|
|
|
|
.then(() => twitterRes)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const uploadTweet = (twitterRes = {}) => client.post('statuses/update', {
|
|
|
|
const uploadTweet = (twitterRes = {}) =>
|
|
|
|
|
|
|
|
client.post('statuses/update', {
|
|
|
|
status: `Carbon Copy #${extractMediaId(twitterRes).slice(0, 8)}`,
|
|
|
|
status: `Carbon Copy #${extractMediaId(twitterRes).slice(0, 8)}`,
|
|
|
|
media_ids: extractMediaId(twitterRes)
|
|
|
|
media_ids: extractMediaId(twitterRes)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const respondSuccess = (res, url) => res.json({ url })
|
|
|
|
const respondSuccess = (res, url) => res.json({ url })
|
|
|
|
const respondFail = (res, err) => {
|
|
|
|
const respondFail = (res, err) => {
|
|
|
|