From bf956606c5d51f8801f727255a3a2ea10fa0c3d7 Mon Sep 17 00:00:00 2001 From: Michael Fix Date: Wed, 20 Sep 2017 20:43:11 -0700 Subject: [PATCH] twitter hash (#14) --- handlers/twitter.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/handlers/twitter.js b/handlers/twitter.js index 0d15e0b..e72b7c8 100644 --- a/handlers/twitter.js +++ b/handlers/twitter.js @@ -10,8 +10,13 @@ const client = new Twitter({ access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET }) -const uploadImage = (data) => client.post('media/upload', { media_data: data }) -const uploadTweet = (media) => client.post('statuses/update', { status: 'Carbon Copy', media_ids: media.media_id_string }) +const uploadImage = data => client.post('media/upload', { media_data: data }) +const uploadTweet = (media = {}) => + client.post('statuses/update', { + status: `Carbon Copy #${media.media_id_string.slice(0, 8)}`, + media_ids: media.media_id_string + }) + const extractImageUrl = morph.get('entities.media.0.display_url') const extractErrorCode = morph.get('0.code') @@ -24,7 +29,7 @@ const respondFail = (res, err) => { return res.status(420).send() } - console.error(`Error: ${errorCode || err.message}`) + console.error(`Error: ${err.message || JSON.stringify(err, null, 2)}`) res.status(500).send() }