updated input msgs and destructuring

This commit is contained in:
bill bittner 2017-09-25 11:55:56 -07:00
parent 250ead165b
commit ede4d4804f
3 changed files with 9 additions and 15 deletions

View file

@ -7,8 +7,6 @@ module.exports = {
publish (publishParams, fileName, fileType) {
return new Promise((resolve, reject) => {
let publishResults = {};
let file;
let claim;
// 1. make sure the name is available
publishHelpers.checkClaimNameAvailability(publishParams.name)
// 2. publish the file
@ -16,7 +14,7 @@ module.exports = {
if (result === true) {
return lbryApi.publishClaim(publishParams);
} else {
return new Error('That name has already been claimed by spee.ch.');
return new Error('That name is already in use by spee.ch.');
}
})
// 3. upsert File record (update is in case the claim has been published before by this daemon)
@ -60,9 +58,7 @@ module.exports = {
// create the records
return Promise.all([db.upsert(db.File, fileRecord, upsertCriteria, 'File'), db.upsert(db.Claim, claimRecord, upsertCriteria, 'Claim')]);
})
.then(result => {
file = result[0];
claim = result[1];
.then(([file, claim]) => {
logger.debug('File and Claim records successfully created');
return Promise.all([file.setClaim(claim), claim.setFile(file)]);
})

View file

@ -29,7 +29,7 @@ module.exports = {
// validate claim name
const invalidCharacters = /[^A-Za-z0-9,-]/.exec(name);
if (invalidCharacters) {
throw new Error('The claim name you provided is not allowed. Only the following characters are allowed: A-Z, a-z, 0-9, and "-"');
throw new Error('The url name you provided is not allowed. Only the following characters are allowed: A-Z, a-z, 0-9, and "-"');
}
// validate license
if ((license.indexOf('Public Domain') === -1) && (license.indexOf('Creative Commons') === -1)) {

View file

@ -15,7 +15,6 @@ module.exports = new PassportLocalStrategy(
logger.debug('new channel signup request');
const address = config.get('WalletConfig.LbryClaimAddress');
let user;
let certificate;
// server-side validaton of inputs (username, password)
// create the channel and retrieve the metadata
@ -26,7 +25,6 @@ module.exports = new PassportLocalStrategy(
channelName : username,
channelClaimId: tx.claim_id,
password : password,
// address,
};
logger.debug('userData >', userData);
// create certificate record
@ -39,16 +37,16 @@ module.exports = new PassportLocalStrategy(
// save user and certificate to db
return Promise.all([db.User.create(userData), db.Certificate.create(certificateData)]);
})
.then(result => {
user = result[0];
certificate = result[1];
.then(([newUser, newCertificate]) => {
user = newUser; // save outside scope of this function
logger.debug('user and certificate successfully created');
logger.debug('user result >', user.dataValues);
logger.debug('certificate result >', certificate.dataValues);
logger.debug('user result >', newUser.dataValues);
logger.debug('certificate result >', newCertificate.dataValues);
// associate the instances
return Promise.all([certificate.setUser(user), user.setCertificate(certificate)]);
return Promise.all([newCertificate.setUser(newUser), newUser.setCertificate(newCertificate)]);
}).then(() => {
logger.debug('user and certificate successfully associated');
logger.debug('user ===', user.dataValues);
return done(null, user);
})
.catch(error => {