2018-04-29 21:17:23 +02:00
|
|
|
const logger = require('winston');
|
|
|
|
|
2018-07-30 22:48:47 +02:00
|
|
|
const db = require('../../models/index');
|
2018-04-29 21:17:23 +02:00
|
|
|
|
|
|
|
const getClaimIdByChannel = (channelName, channelClaimId, claimName) => {
|
2018-08-08 20:39:35 +02:00
|
|
|
logger.debug(`getClaimIdByChannel(${channelName}, ${channelClaimId}, ${claimName})`);
|
|
|
|
return db.Certificate
|
|
|
|
.getLongChannelId(channelName, channelClaimId)
|
|
|
|
.then(longChannelId => {
|
|
|
|
return db.Claim.getClaimIdByLongChannelId(longChannelId, claimName);
|
|
|
|
});
|
2018-04-29 21:17:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const getClaimId = (channelName, channelClaimId, name, claimId) => {
|
2018-08-08 20:39:35 +02:00
|
|
|
logger.debug(`getClaimId: ${channelName}, ${channelClaimId}, ${name}, ${claimId})`);
|
2018-04-29 21:17:23 +02:00
|
|
|
if (channelName) {
|
|
|
|
return getClaimIdByChannel(channelName, channelClaimId, name);
|
|
|
|
} else {
|
|
|
|
return db.Claim.getLongClaimId(name, claimId);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = getClaimId;
|