spee.ch/server/controllers/api/channel/data/getChannelData.js

29 lines
760 B
JavaScript
Raw Normal View History

2018-04-27 18:54:36 +02:00
const db = require('../../../../models');
const getChannelData = (channelName, channelClaimId) => {
2018-04-27 18:54:36 +02:00
return new Promise((resolve, reject) => {
let longChannelClaimId;
2018-04-27 18:54:36 +02:00
// 1. get the long channel Id (make sure channel exists)
db.Certificate
.getLongChannelId(channelName, channelClaimId)
.then(fullClaimId => {
longChannelClaimId = fullClaimId;
return db
.Certificate
.getShortChannelIdFromLongChannelId(fullClaimId, channelName);
2018-04-27 18:54:36 +02:00
})
.then(shortChannelClaimId => {
2018-04-27 18:54:36 +02:00
resolve({
channelName,
longChannelClaimId,
shortChannelClaimId,
});
})
.catch(error => {
reject(error);
});
});
};
module.exports = getChannelData;