Separated pay, claim, and change wallet addresses #44

Merged
bones7242 merged 3 commits from separate-wallets into master 2017-06-29 21:38:37 +02:00
4 changed files with 21 additions and 13 deletions
Showing only changes of commit c0174fb300 - Show all commits

View file

@ -4,9 +4,15 @@ const logger = require('winston');
module.exports = { module.exports = {
postToAnalytics: (action, url, ipAddress, result) => { postToAnalytics: (action, url, ipAddress, result) => {
logger.silly('creating record for analytics'); logger.silly('creating record for analytics');
// make sure the result is a string
if (result && (typeof result !== 'string')) { if (result && (typeof result !== 'string')) {
result = result.toString(); result = result.toString();
} }
// // make sure the ip address(es) are a string
if (ipAddress && (typeof ipAddress !== 'string')) {
ipAddress = ipAddress.toString();
}
// create record in the db
db.Analytics.create({ db.Analytics.create({
action, action,
url, url,

View file

@ -7,7 +7,7 @@ module.exports = {
logger.debug(`Creating Publish Parameters for "${name}"`); logger.debug(`Creating Publish Parameters for "${name}"`);
// const payAddress = config.get('WalletConfig.LbryPayAddress'); // const payAddress = config.get('WalletConfig.LbryPayAddress');
const claimAddress = config.get('WalletConfig.LbryClaimAddress'); const claimAddress = config.get('WalletConfig.LbryClaimAddress');
const changeAddress = config.get('WalletConfig.LbryChangeAddress'); // const changeAddress = config.get('WalletConfig.LbryChangeAddress');
// ensure nsfw is a boolean // ensure nsfw is a boolean
if (nsfw === false) { if (nsfw === false) {
nsfw = false; nsfw = false;
@ -34,8 +34,8 @@ module.exports = {
license, license,
nsfw, nsfw,
}, },
claim_address : claimAddress, claim_address: claimAddress,
change_address: changeAddress, //change_address: changeAddress,
}; };
logger.debug('publishParams:', publishParams); logger.debug('publishParams:', publishParams);
return publishParams; return publishParams;

View file

@ -34,31 +34,33 @@ function serveFile ({ fileName, fileType, filePath }, res) {
module.exports = (app) => { module.exports = (app) => {
// route to fetch one free public claim // route to fetch one free public claim
app.get('/:name/:claim_id', ({ originalUrl, params, ip }, res) => { app.get('/:name/:claim_id', ({ originalUrl, params, ips, headers }, res) => {
logger.debug(`GET request on ${originalUrl} from ${ip}`); logger.debug(`GET request on ${originalUrl} from ${ips}`);
logger.debug(`headers ${headers}`);
// begin image-serve processes // begin image-serve processes
serveController serveController
.getClaimByClaimId(params.name, params.claim_id) .getClaimByClaimId(params.name, params.claim_id)
.then(fileInfo => { .then(fileInfo => {
postToAnalytics('serve', originalUrl, ip, 'success'); postToAnalytics('serve', originalUrl, ips, 'success');
serveFile(fileInfo, res); serveFile(fileInfo, res);
}) })
.catch(error => { .catch(error => {
errorHandlers.handleRequestError('serve', originalUrl, ip, error, res); errorHandlers.handleRequestError('serve', originalUrl, ips, error, res);
}); });
}); });
// route to fetch one free public claim // route to fetch one free public claim
app.get('/:name', ({ originalUrl, params, ip }, res) => { app.get('/:name', ({ originalUrl, params, ips, headers }, res) => {
logger.debug(`GET request on ${originalUrl} from ${ip}`); logger.debug(`GET request on ${originalUrl} from ${ips}`);
logger.debug(`headers ${headers}`);
// begin image-serve processes // begin image-serve processes
serveController serveController
.getClaimByName(params.name) .getClaimByName(params.name)
.then(fileInfo => { .then(fileInfo => {
postToAnalytics('serve', originalUrl, ip, 'success'); postToAnalytics('serve', originalUrl, ips, 'success');
serveFile(fileInfo, res); serveFile(fileInfo, res);
}) })
.catch(error => { .catch(error => {
errorHandlers.handleRequestError('serve', originalUrl, ip, error, res); errorHandlers.handleRequestError('serve', originalUrl, ips, error, res);
}); });
}); });
}; };

View file

@ -16,12 +16,12 @@ require('./config/loggerSetup.js')(winston, logLevel, logDir);
// set port // set port
const PORT = 3000; const PORT = 3000;
// initialize express app // create an Express application
const app = express(); const app = express();
// require our models for syncing // require our models for syncing
const db = require('./models'); const db = require('./models');
// make express look in the public directory for assets (css/js/img) // serve static files from public directory (css/js/img)
app.use(express.static(`${__dirname}/public`)); app.use(express.static(`${__dirname}/public`));
// configure express app // configure express app