diff --git a/controllers/serveController.js b/controllers/serveController.js index 2c0f55cf..07825684 100644 --- a/controllers/serveController.js +++ b/controllers/serveController.js @@ -111,8 +111,7 @@ module.exports = { logger.debug('getting asset by claim'); return new Promise((resolve, reject) => { db.getLongClaimId(claimName, claimId) // 1. get the long claim id - // 2. get the claim Id - .then(result => { + .then(result => { // 2. get the asset using the long claim id if (result === NO_CLAIM || !result) { resolve(NO_CLAIM); return; @@ -129,18 +128,21 @@ module.exports = { logger.debug('getting asset by channel'); return new Promise((resolve, reject) => { db.getLongChannelId(channelName, channelId) // 1. get the long channel id - .then(result => { // 2. get the claim Id - if (result === NO_CHANNEL) { - resolve(result); + .then(result => { // 2. get the long claim Id + if (result === NO_CHANNEL || !result) { + resolve(NO_CHANNEL); return; } return db.getClaimIdByLongChannelId(result, claimName); }) - .then(result => { // 3. get the asset by this claim id and name + .then(result => { // 3. get the asset using the long claim id logger.debug('asset claim id =', result); if (result === NO_CHANNEL || result === NO_CLAIM) { resolve(result); return; + } else if (!result) { + resolve(NO_CLAIM); + return; } resolve(getAssetByLongClaimId(result, claimName)); }) @@ -153,8 +155,7 @@ module.exports = { return new Promise((resolve, reject) => { let longChannelId; let shortChannelId; - db - .getLongChannelId(channelName, channelId) // 1. get the long channel Id + db.getLongChannelId(channelName, channelId) // 1. get the long channel Id .then(result => { // 2. get all claims for that channel if (result === NO_CHANNEL) { return NO_CHANNEL; @@ -179,6 +180,7 @@ module.exports = { const fileExtenstion = element.contentType.substring(element.contentType.lastIndexOf('/') + 1); element['showUrlLong'] = `/${channelName}:${longChannelId}/${element.name}`; element['directUrlLong'] = `/${channelName}:${longChannelId}/${element.name}.${fileExtenstion}`; + element['showUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}`; element['directUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}.${fileExtenstion}`; element['thumbnail'] = chooseThumbnail(element, DEFAULT_THUMBNAIL); }); diff --git a/helpers/errorHandlers.js b/helpers/errorHandlers.js index eaea043e..b127cd90 100644 --- a/helpers/errorHandlers.js +++ b/helpers/errorHandlers.js @@ -3,7 +3,7 @@ const { postToStats } = require('../controllers/statsController.js'); module.exports = { handleRequestError (action, originalUrl, ip, error, res) { - logger.error('Request Error:', module.exports.useObjectPropertiesIfNoKeys(error)); + logger.error(`Request Error: ${originalUrl}`, module.exports.useObjectPropertiesIfNoKeys(error)); postToStats(action, originalUrl, ip, null, null, error); if (error.response) { res.status(error.response.status).send(error.response.data.error.message); diff --git a/routes/page-routes.js b/routes/page-routes.js index 14e6682f..9f64941e 100644 --- a/routes/page-routes.js +++ b/routes/page-routes.js @@ -36,7 +36,7 @@ module.exports = (app) => { }); }) .catch(error => { - errorHandlers.handleRequestError(error, res); + errorHandlers.handleRequestError(null, null, null, error, res); }); }); // route to display a list of the trending images @@ -49,7 +49,7 @@ module.exports = (app) => { }); }) .catch(error => { - errorHandlers.handleRequestError(error, res); + errorHandlers.handleRequestError(null, null, null, error, res); }); }); // route to show statistics for spee.ch @@ -66,7 +66,7 @@ module.exports = (app) => { }); }) .catch(error => { - errorHandlers.handleRequestError(error, res); + errorHandlers.handleRequestError(null, null, null, error, res); }); }); // route to send embedable video player (for twitter) diff --git a/routes/serve-routes.js b/routes/serve-routes.js index 55b85a33..02e66555 100644 --- a/routes/serve-routes.js +++ b/routes/serve-routes.js @@ -142,8 +142,8 @@ module.exports = (app) => { getAsset(claimOrChannel, channelName, channelId, name, claimId) // 2. serve or show .then(result => { - if (result === NO_CLAIM) { - res.status(200).json({success: true, message: 'no matching claims were found'}); // res.status(200).render('noClaims'); + if (!result || result === NO_CLAIM) { + res.status(200).json({success: true, message: 'no matching claims were found'}); return; } else if (result === NO_CHANNEL) { res.status(200).json({success: true, message: 'no matching channel was found'}); diff --git a/views/partials/contentListItem.handlebars b/views/partials/contentListItem.handlebars index 3472285c..135d3958 100644 --- a/views/partials/contentListItem.handlebars +++ b/views/partials/contentListItem.handlebars @@ -1,14 +1,15 @@
- + {{#ifConditional this.contentType '===' 'video/mp4'}} {{else}} {{/ifConditional}} +

{{this.title}}

- spee.ch{{this.directUrlShort}} + spee.ch{{this.showUrlShort}}