added channel oEmbed route

This commit is contained in:
bill bittner 2018-07-30 15:51:01 -07:00
parent b401919bb4
commit e22b676581

View file

@ -1,17 +1,28 @@
const logger = require('winston'); const logger = require('winston');
const db = require('../../../models');
const getOEmbedDataForChannel = (channelName, channelClaimId) => { const getOEmbedDataForChannel = (channelName, channelClaimId) => {
logger.debug('get oembed for channel:', `${channelName}:${channelClaimId}`); logger.debug('get oembed for channel:', `${channelName}:${channelClaimId}`);
return new Promise((resolve, reject) => { return db.Certificate
resolve({ .findOne({
version : 1.0, where: {
author_name : 'Spee.ch', name : channelName,
author_url : 'https://spee.ch', claimId: channelClaimId,
provider_name: 'Spee.ch', },
provider_url : 'https://spee.ch', })
cache_age : 86400, // one day in seconds .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; module.exports = getOEmbedDataForChannel;