Skip to content
This repository has been archived by the owner on May 22, 2021. It is now read-only.

removed bitly integration #123

Merged
merged 2 commits into from
Jun 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions server/config.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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';
28 changes: 4 additions & 24 deletions server/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
});
}
});
});
Expand Down
3 changes: 1 addition & 2 deletions test/aws.storage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {});
Expand Down