added channel oEmbed route
This commit is contained in:
parent
b401919bb4
commit
e22b676581
1 changed files with 20 additions and 9 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue