From e22b6765818732c3a2a571c6b466256d14dd98b5 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 30 Jul 2018 15:51:01 -0700 Subject: [PATCH] added channel oEmbed route --- .../api/oEmbed/getOEmbedDataForChannel.js | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/server/controllers/api/oEmbed/getOEmbedDataForChannel.js b/server/controllers/api/oEmbed/getOEmbedDataForChannel.js index 47241353..1cd9d4a4 100644 --- a/server/controllers/api/oEmbed/getOEmbedDataForChannel.js +++ b/server/controllers/api/oEmbed/getOEmbedDataForChannel.js @@ -1,17 +1,28 @@ const logger = require('winston'); +const db = require('../../../models'); const getOEmbedDataForChannel = (channelName, channelClaimId) => { logger.debug('get oembed for channel:', `${channelName}:${channelClaimId}`); - return new Promise((resolve, reject) => { - resolve({ - version : 1.0, - author_name : 'Spee.ch', - author_url : 'https://spee.ch', - provider_name: 'Spee.ch', - provider_url : 'https://spee.ch', - cache_age : 86400, // one day in seconds + return db.Certificate + .findOne({ + where: { + name : channelName, + claimId: channelClaimId, + }, + }) + .then(certificateRecord => { + const certificateData = certificateRecord.dataValues; + return { + version : 1.0, + provider_name: 'Spee.ch', + provider_url : 'https://spee.ch', + type : 'link', + author_name : certificateData.name, + title : `${certificateData.name}'s channel on Spee.ch`, + author_url : `https://spee.ch/${certificateData.name}:${certificateData.claimId}`, + cache_age : 86400, // one day in seconds + }; }); - }); }; module.exports = getOEmbedDataForChannel;