From 60fd36a58eee6b3a926ff961db6693cce9d7284e Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Thu, 22 Jun 2017 15:32:52 -0700 Subject: [PATCH] removed bitly integration --- server/config.js | 8 +------- server/storage.js | 28 ++++------------------------ test/aws.storage.test.js | 3 +-- 3 files changed, 6 insertions(+), 33 deletions(-) diff --git a/server/config.js b/server/config.js index 4bf9465e..5a01e627 100644 --- a/server/config.js +++ b/server/config.js @@ -1,11 +1,6 @@ const convict = require('convict'); const conf = convict({ - bitly_key: { - format: String, - default: 'localhost', - env: 'P2P_BITLY_KEY' - }, s3_bucket: { format: String, default: 'localhost', @@ -47,5 +42,4 @@ module.exports = props; module.exports.notLocalHost = props.env === 'production' && - props.s3_bucket !== 'localhost' && - props.bitly_key !== 'localhost'; + props.s3_bucket !== 'localhost'; diff --git a/server/storage.js b/server/storage.js index e3af4440..4acca3e6 100644 --- a/server/storage.js +++ b/server/storage.js @@ -4,7 +4,6 @@ const s3 = new AWS.S3(); const conf = require('./config.js'); const fs = require('fs'); const path = require('path'); -const fetch = require('node-fetch'); const crypto = require('crypto'); const notLocalHost = conf.notLocalHost; @@ -170,29 +169,10 @@ function awsSet(id, file, filename, url) { redis_client.expire(id, 86400000); log.info('awsUploadFinish', 'Upload Finished of ' + filename); - if (conf.bitly_key) { - fetch( - 'https://api-ssl.bitly.com/v3/shorten?access_token=' + - conf.bitly_key + - '&longUrl=' + - encodeURIComponent(url) + - '&format=txt' - ) - .then(res => { - return res.text(); - }) - .then(body => { - resolve({ - uuid: uuid, - url: body - }); - }); - } else { - resolve({ - uuid: uuid, - url: url - }); - } + resolve({ + uuid: uuid, + url: url + }); } }); }); diff --git a/test/aws.storage.test.js b/test/aws.storage.test.js index a0778766..20b180b6 100644 --- a/test/aws.storage.test.js +++ b/test/aws.storage.test.js @@ -107,8 +107,7 @@ describe('Testing Set using aws', function() { crypto.randomBytes.restore(); }); - it('Should pass when the file is successfully uploaded and no bitly key', function() { - conf.bitly_key = null; + it('Should pass when the file is successfully uploaded', function() { const buf = Buffer.alloc(10); sinon.stub(crypto, 'randomBytes').returns(buf); s3Stub.upload.callsArgWith(1, null, {});