DRYer default thumbnail code
This commit is contained in:
parent
6158ef9724
commit
3389d3759f
1 changed files with 10 additions and 8 deletions
|
@ -7,6 +7,7 @@ const { postToStats, sendGoogleAnalytics } = require('../controllers/statsContro
|
||||||
const SERVE = 'SERVE';
|
const SERVE = 'SERVE';
|
||||||
const SHOW = 'SHOW';
|
const SHOW = 'SHOW';
|
||||||
const SHOWLITE = 'SHOWLITE';
|
const SHOWLITE = 'SHOWLITE';
|
||||||
|
const DEFAULT_THUMBNAIL = 'https://spee.ch/assets/img/content-freedom-large.png';
|
||||||
|
|
||||||
function checkForLocalAssetByClaimId (claimId, name) {
|
function checkForLocalAssetByClaimId (claimId, name) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
@ -95,6 +96,13 @@ function getAssetByLongClaimId (fullClaimId, name) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function chooseThumbnail (claimInfo, defaultThumbnail) {
|
||||||
|
if (!claimInfo.thumbnail || claimInfo.thumbnail === '') {
|
||||||
|
return defaultThumbnail;
|
||||||
|
}
|
||||||
|
return claimInfo.thumbnail;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getAssetByClaim (claimName, claimId) {
|
getAssetByClaim (claimName, claimId) {
|
||||||
logger.debug('getting asset by claim');
|
logger.debug('getting asset by claim');
|
||||||
|
@ -157,9 +165,7 @@ module.exports = {
|
||||||
element['showUrlLong'] = `/${channelName}:${longChannelId}/${element.name}`;
|
element['showUrlLong'] = `/${channelName}:${longChannelId}/${element.name}`;
|
||||||
element['directUrlLong'] = `/${channelName}:${longChannelId}/${element.name}.${fileExtenstion}`;
|
element['directUrlLong'] = `/${channelName}:${longChannelId}/${element.name}.${fileExtenstion}`;
|
||||||
element['directUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}.${fileExtenstion}`;
|
element['directUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}.${fileExtenstion}`;
|
||||||
if (!element.thumbnail || element.thumbnail === '') {
|
element['thumbnail'] = chooseThumbnail(element, DEFAULT_THUMBNAIL);
|
||||||
element['thumbnail'] = 'https://spee.ch/assets/img/content-freedom-large.png';
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return resolve(allChannelClaims);
|
return resolve(allChannelClaims);
|
||||||
|
@ -195,11 +201,7 @@ module.exports = {
|
||||||
return db.resolveClaim(fileInfo.name, fileInfo.claimId);
|
return db.resolveClaim(fileInfo.name, fileInfo.claimId);
|
||||||
})
|
})
|
||||||
.then(resolveResult => {
|
.then(resolveResult => {
|
||||||
if (!resolveResult.thumbnail || resolveResult.thumbnail === '') {
|
fileInfo['thumbnail'] = chooseThumbnail(resolveResult, DEFAULT_THUMBNAIL);
|
||||||
fileInfo['thumbnail'] = 'https://spee.ch/assets/img/content-freedom-large.png';
|
|
||||||
} else {
|
|
||||||
fileInfo['thumbnail'] = resolveResult.thumbnail;
|
|
||||||
}
|
|
||||||
fileInfo['title'] = resolveResult.title;
|
fileInfo['title'] = resolveResult.title;
|
||||||
fileInfo['description'] = resolveResult.description;
|
fileInfo['description'] = resolveResult.description;
|
||||||
showFile(fileInfo, res);
|
showFile(fileInfo, res);
|
||||||
|
|
Loading…
Reference in a new issue