added check for no claim and updated request error message with ip address

This commit is contained in:
bill bittner 2017-10-18 09:49:19 -07:00
parent 0a62df1d76
commit 607ca4d98c
5 changed files with 19 additions and 16 deletions

View file

@ -111,8 +111,7 @@ module.exports = {
logger.debug('getting asset by claim');
return new Promise((resolve, reject) => {
db.getLongClaimId(claimName, claimId) // 1. get the long claim id
// 2. get the claim Id
.then(result => {
.then(result => { // 2. get the asset using the long claim id
if (result === NO_CLAIM || !result) {
resolve(NO_CLAIM);
return;
@ -129,18 +128,21 @@ module.exports = {
logger.debug('getting asset by channel');
return new Promise((resolve, reject) => {
db.getLongChannelId(channelName, channelId) // 1. get the long channel id
.then(result => { // 2. get the claim Id
if (result === NO_CHANNEL) {
resolve(result);
.then(result => { // 2. get the long claim Id
if (result === NO_CHANNEL || !result) {
resolve(NO_CHANNEL);
return;
}
return db.getClaimIdByLongChannelId(result, claimName);
})
.then(result => { // 3. get the asset by this claim id and name
.then(result => { // 3. get the asset using the long claim id
logger.debug('asset claim id =', result);
if (result === NO_CHANNEL || result === NO_CLAIM) {
resolve(result);
return;
} else if (!result) {
resolve(NO_CLAIM);
return;
}
resolve(getAssetByLongClaimId(result, claimName));
})
@ -153,8 +155,7 @@ module.exports = {
return new Promise((resolve, reject) => {
let longChannelId;
let shortChannelId;
db
.getLongChannelId(channelName, channelId) // 1. get the long channel Id
db.getLongChannelId(channelName, channelId) // 1. get the long channel Id
.then(result => { // 2. get all claims for that channel
if (result === NO_CHANNEL) {
return NO_CHANNEL;
@ -179,6 +180,7 @@ module.exports = {
const fileExtenstion = element.contentType.substring(element.contentType.lastIndexOf('/') + 1);
element['showUrlLong'] = `/${channelName}:${longChannelId}/${element.name}`;
element['directUrlLong'] = `/${channelName}:${longChannelId}/${element.name}.${fileExtenstion}`;
element['showUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}`;
element['directUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}.${fileExtenstion}`;
element['thumbnail'] = chooseThumbnail(element, DEFAULT_THUMBNAIL);
});