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

26 lines
866 B
JavaScript
Raw Normal View History

const db = require('server/models');
2018-12-14 18:42:37 +01:00
const chainquery = require('chainquery').default;
2018-04-27 18:54:36 +02:00
const getChannelData = async (channelName, channelClaimId) => {
let longChannelClaimId = await chainquery.claim.queries.getLongClaimId(channelName, channelClaimId).catch(() => false);
2018-11-11 01:11:12 +01:00
if (!longChannelClaimId) {
// Allow an error to throw here if this fails
longChannelClaimId = await db.Certificate.getLongChannelId(channelName, channelClaimId);
}
let shortChannelClaimId = await chainquery.claim.queries.getShortClaimIdFromLongClaimId(longChannelClaimId, channelName).catch(() => false);
2018-11-11 01:11:12 +01:00
if (!shortChannelClaimId) {
shortChannelClaimId = await db.Certificate.getShortChannelIdFromLongChannelId(longChannelClaimId, channelName);
}
return {
channelName,
longChannelClaimId,
shortChannelClaimId,
};
2018-04-27 18:54:36 +02:00
};
module.exports = getChannelData;