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 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;