2018-09-26 03:20:59 +02:00
|
|
|
const { details: { host } } = require('@config/siteConfig');
|
2018-10-10 02:11:06 +02:00
|
|
|
const chainquery = require('chainquery');
|
2018-09-26 03:20:59 +02:00
|
|
|
|
2018-10-10 02:11:06 +02:00
|
|
|
module.exports = async (data) => {
|
|
|
|
// TODO: Refactor getching the channel name out; requires invasive changes.
|
|
|
|
const certificateId = data.publisher_id || data.certificateId;
|
|
|
|
let channelName = data.channelName;
|
|
|
|
|
|
|
|
if(certificateId && !channelName) {
|
|
|
|
channelName = await chainquery.claim.queries.getClaimChannelName(certificateId).catch(()=>{});
|
|
|
|
}
|
|
|
|
|
2018-10-29 15:09:26 +01:00
|
|
|
let channelShortId = null;
|
|
|
|
if (certificateId && channelName) {
|
|
|
|
channelShortId = await chainquery.claim.queries.getShortClaimIdFromLongClaimId(certificateId, channelName).catch(() => null);
|
|
|
|
}
|
|
|
|
|
2018-10-10 02:11:06 +02:00
|
|
|
return ({
|
|
|
|
name: data.name,
|
|
|
|
title: data.title,
|
|
|
|
certificateId,
|
|
|
|
channelName,
|
2018-10-29 15:09:26 +01:00
|
|
|
channelShortId,
|
2018-10-10 02:11:06 +02:00
|
|
|
contentType: data.content_type || data.contentType,
|
|
|
|
claimId: data.claim_id || data.claimId,
|
|
|
|
fileExt: data.generated_extension || data.fileExt,
|
|
|
|
description: data.description,
|
|
|
|
thumbnail: data.generated_thumbnail || data.thumbnail,
|
|
|
|
outpoint: data.transaction_hash_id || data.outpoint,
|
|
|
|
host,
|
|
|
|
})
|
|
|
|
}
|