Merge pull request #123 from mozilla/remove-bitly
removed bitly integration
This commit is contained in:
commit
e1bd4d934b
@ -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';
|
||||
|
@ -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,30 +169,11 @@ 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
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -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, {});
|
||||
|
Loading…
Reference in New Issue
Block a user