fixed substring issue and added no claim/no channel pages

This commit is contained in:
bill bittner 2017-10-18 11:16:07 -07:00
parent b0d88263c7
commit ab14adca00
5 changed files with 20 additions and 16 deletions

View file

@ -108,15 +108,16 @@ function chooseThumbnail (claimInfo, defaultThumbnail) {
module.exports = {
getAssetByClaim (claimName, claimId) {
logger.debug('getting asset by claim');
logger.debug(`getAssetByClaim(${claimName}, ${claimId})`);
return new Promise((resolve, reject) => {
db.getLongClaimId(claimName, claimId) // 1. get the long claim id
.then(result => { // 2. get the asset using the long claim id
logger.debug('getLongClaimId result:', result);
if (result === NO_CLAIM) {
logger.debug('resolving NO_CLAIM');
resolve(NO_CLAIM);
return;
}
logger.debug('long claim id = ', result);
resolve(getAssetByLongClaimId(result, claimName));
})
.catch(error => {

View file

@ -71,6 +71,7 @@ function getTopFreeClaimIdByClaimName (name) {
db
.sequelize.query(`SELECT claimId FROM Claim WHERE name = '${name}' ORDER BY effectiveAmount DESC, height ASC LIMIT 1`, { type: db.sequelize.QueryTypes.SELECT })
.then(result => {
logger.debug('getTopFreeClaimIdByClaimName result:', result);
switch (result.length) {
case 0:
return resolve(NO_CLAIM);

View file

@ -142,11 +142,12 @@ module.exports = (app) => {
getAsset(claimOrChannel, channelName, channelId, name, claimId)
// 2. serve or show
.then(result => {
if (!result || result === NO_CLAIM) {
res.status(200).json({success: true, message: 'no matching claims were found'});
logger.debug('getAsset result:', result);
if (result === NO_CLAIM) {
res.status(200).render('noClaim');
return;
} else if (result === NO_CHANNEL) {
res.status(200).json({success: true, message: 'no matching channel was found'});
res.status(200).render('noChannel');
return;
}
return serveOrShowAsset(result, fileExtension, method, headers, originalUrl, ip, res);
@ -183,7 +184,7 @@ module.exports = (app) => {
// 2. respond to the request
.then(result => {
if (result === NO_CHANNEL) { // no channel found
res.status(200).json({ success: true, message: 'no matching channel found' });
res.status(200).render('noChannel');
} else if (!result.claims) { // channel found, but no claims
res.status(200).render('channel', {
channelName : result.channelName,
@ -235,11 +236,12 @@ module.exports = (app) => {
// 1. retrieve the asset and information
getAsset(CLAIM, null, null, name, null)
// 2. respond to the request
.then(fileInfo => {
if (!fileInfo) {
res.status(200).render('noClaims');
.then(result => {
logger.debug('getAsset result', result);
if (result === NO_CLAIM) {
res.status(200).render('noClaim');
} else {
return serveOrShowAsset(fileInfo, fileExtension, method, headers, originalUrl, ip, res);
return serveOrShowAsset(result, fileExtension, method, headers, originalUrl, ip, res);
}
})
// 3. update the database

View file

@ -1,5 +1,5 @@
<div>
<h3>No Claims</h3>
<p>There are no free assets on this channel.</p>
<p><i>If you think this message is an error, contact us in the <a href="https://lbry.slack.com/" target="_blank">LBRY slack!</a></i></p>
<div class="row">
<h3>[No Channel]</h3>
<p>There are no published channels matching your url</p>
<p>If you think this message is an error, contact us in the <a href="https://lbry.slack.com/" target="_blank">LBRY slack!</a></p>
</div>

View file

@ -1,5 +1,5 @@
<div class="row">
<h3>No Claims</h3>
<h3>[No Claims]</h3>
<p>There are no free assets at that claim. You should publish one at <a href="/">spee.ch</a>.</p>
<p>NOTE: it is possible your claim was published, but it is still being processed by the blockchain</p>
</div>