spee.ch/server/controllers/api/oEmbed/getOEmbedDataForChannel.js

34 lines
880 B
JavaScript
Raw Normal View History

2018-07-31 00:51:01 +02:00
const db = require('../../../models');
const {
details: {
host,
title: siteTitle,
},
} = require('@config/siteConfig');
const getOEmbedDataForChannel = (channelName, channelClaimId) => {
2018-07-31 00:51:01 +02:00
return db.Certificate
.findOne({
where: {
name : channelName,
claimId: channelClaimId,
},
})
.then(certificateRecord => {
const certificateData = certificateRecord.dataValues;
return {
version : 1.0,
provider_name: siteTitle,
provider_url : host,
2018-07-31 00:51:01 +02:00
type : 'link',
author_name : certificateData.name,
title : `${certificateData.name}'s channel on Spee.ch`,
author_url : `${host}/${certificateData.name}:${certificateData.claimId}`,
2018-07-31 00:51:01 +02:00
cache_age : 86400, // one day in seconds
};
});
};
module.exports = getOEmbedDataForChannel;