Authentication #170

Merged
bones7242 merged 43 commits from authentication into master 2017-09-29 02:29:22 +02:00
5 changed files with 34 additions and 4 deletions
Showing only changes of commit 65b5384330 - Show all commits

View file

@ -150,7 +150,7 @@ module.exports = {
// 2. get all claims for that channel
.then(result => {
longChannelId = result;
return db.getShortChannelIdFromLongChannelId(channelName, longChannelId);
return db.getShortChannelIdFromLongChannelId(longChannelId, channelName);
})
// 3. get all Claim records for this channel
.then(result => {

View file

@ -190,7 +190,7 @@ db['getShortClaimIdFromLongClaimId'] = (claimId, claimName) => {
});
};
db['getShortChannelIdFromLongChannelId'] = (channelName, longChannelId) => {
db['getShortChannelIdFromLongChannelId'] = (longChannelId, channelName) => {
return new Promise((resolve, reject) => {
logger.debug('finding short channel id');
db

View file

@ -1,6 +1,7 @@
const logger = require('winston');
const multipart = require('connect-multiparty');
const multipartMiddleware = multipart();
const db = require('../models');
const { publish } = require('../controllers/publishController.js');
const { getClaimList, resolveUri } = require('../helpers/lbryApi.js');
const { createPublishParams, validateFile, checkClaimNameAvailability, checkChannelAvailability } = require('../helpers/publishHelpers.js');
@ -69,7 +70,6 @@ module.exports = (app) => {
errorHandlers.handleRequestError('publish', originalUrl, ip, error, res);
});
});
// route to run a publish request on the daemon
app.post('/api/publish', multipartMiddleware, ({ body, files, headers, ip, originalUrl }, res) => {
// google analytics
@ -104,9 +104,11 @@ module.exports = (app) => {
}
return createPublishParams(name, filePath, title, description, license, nsfw, channelName);
})
// create publish parameters object
.then(publishParams => {
return publish(publishParams, fileName, fileType);
})
// publish the asset
.then(result => {
postToStats('publish', originalUrl, ip, null, null, 'success');
res.status(200).json(result);
@ -115,4 +117,28 @@ module.exports = (app) => {
logger.error('publish api error', error);
});
});
// route to get a short claim id from long claim Id
app.get('/api/shortClaimId/:longId/:name', ({ originalUrl, ip, params }, res) => {
// serve content
db.getShortClaimIdFromLongClaimId(params.longId, params.name)
.then(shortId => {
res.status(200).json(shortId);
})
.catch(error => {
logger.error('api error getting short channel id', error);
res.status(400).json(error.message);
});
});
// route to get a short channel id from long channel Id
app.get('/api/shortChannelId/:longId/:name', ({ params }, res) => {
// serve content
db.getShortChannelIdFromLongChannelId(params.longId, params.name)
.then(shortId => {
res.status(200).json(shortId);
})
.catch(error => {
logger.error('api error getting short channel id', error);
res.status(400).json(error.message);
});
});
};

View file

@ -55,6 +55,9 @@
if (selectedOption === 'none'){
urlChannel.innerText = '';
} else {
// retrieve short url from db
// update url text
urlChannel.innerText = `${selectedOption}/`;
}

View file

@ -10,4 +10,5 @@
</div>
</div>
</div>
</div>