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;