2018-07-31 00:51:01 +02:00
|
|
|
const db = require('../../../models');
|
2018-07-30 23:22:02 +02:00
|
|
|
|
2018-07-31 18:24:03 +02:00
|
|
|
const {
|
|
|
|
details: {
|
|
|
|
host,
|
|
|
|
title: siteTitle,
|
|
|
|
},
|
|
|
|
} = require('@config/siteConfig');
|
|
|
|
|
2018-07-30 23:22:02 +02:00
|
|
|
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,
|
2018-07-31 18:24:03 +02:00
|
|
|
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`,
|
2018-07-31 18:24:03 +02:00
|
|
|
author_url : `${host}/${certificateData.name}:${certificateData.claimId}`,
|
2018-07-31 00:51:01 +02:00
|
|
|
cache_age : 86400, // one day in seconds
|
|
|
|
};
|
2018-07-30 23:22:02 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = getOEmbedDataForChannel;
|