diff --git a/controllers/serveController.js b/controllers/serveController.js index 89561251..f4f8a570 100644 --- a/controllers/serveController.js +++ b/controllers/serveController.js @@ -192,6 +192,12 @@ module.exports = { return db.resolveClaim(fileInfo.name, fileInfo.claimId); }) .then(resolveResult => { + logger.debug(resolveResult); + if (!resolveResult.thumbnail || resolveResult.thumbnail === '') { + fileInfo['thumbnail'] = 'https://spee.ch/assets/img/content-freedom-large.png'; + } else { + fileInfo['thumbnail'] = resolveResult.thumbnail; + } fileInfo['title'] = resolveResult.title; fileInfo['description'] = resolveResult.description; showFile(fileInfo, res); diff --git a/models/index.js b/models/index.js index dd044653..4c5a7187 100644 --- a/models/index.js +++ b/models/index.js @@ -226,7 +226,7 @@ db['getAllFreeClaims'] = (name) => { db['resolveClaim'] = (name, claimId) => { return new Promise((resolve, reject) => { db - .sequelize.query(`SELECT name, claimId, outpoint, height, address, title, description FROM Claim WHERE name = '${name}' AND claimId = '${claimId}'`, { type: db.sequelize.QueryTypes.SELECT }) + .sequelize.query(`SELECT name, claimId, outpoint, height, address, title, description, thumbnail FROM Claim WHERE name = '${name}' AND claimId = '${claimId}'`, { type: db.sequelize.QueryTypes.SELECT }) .then(result => { switch (result.length) { case 0: diff --git a/speech.js b/speech.js index be0de1ab..259d0837 100644 --- a/speech.js +++ b/speech.js @@ -48,14 +48,14 @@ const hbs = expressHandlebars.create({ ` ); }, - addOpenGraph (title, mimeType, showUrl, source, description) { + addOpenGraph (title, mimeType, showUrl, source, description, thumbnail) { let basicTags = ` `; if (mimeType === 'video/mp4') { return new Handlebars.SafeString( - `${basicTags} + `${basicTags} diff --git a/views/layouts/show.handlebars b/views/layouts/show.handlebars index 814c130d..0bf410fb 100644 --- a/views/layouts/show.handlebars +++ b/views/layouts/show.handlebars @@ -9,8 +9,8 @@ {{#unless fileInfo.nsfw}} - {{{addTwitterCard fileInfo.fileType openGraphInfo.source openGraphInfo.embedUrl openGraphInfo.directFileUrl}}} - {{{addOpenGraph fileInfo.title fileInfo.fileType openGraphInfo.showUrl openGraphInfo.source fileInfo.description}}} + {{{addTwitterCard fileInfo.fileType openGraphInfo.source openGraphInfo.embedUrl openGraphInfo.directFileUrl}}} + {{{addOpenGraph fileInfo.title fileInfo.fileType openGraphInfo.showUrl openGraphInfo.source fileInfo.description fileInfo.thumbnail}}} {{/unless}} {{ googleAnalytics }}