added availability check based on multiple claim addresses

This commit is contained in:
bill bittner 2018-03-07 20:06:52 -08:00
parent 188706ca31
commit d018f58d8d
3 changed files with 12 additions and 12 deletions

View file

@ -1,7 +1,4 @@
module.exports = {
wallet: {
lbryClaimAddress: null, // choose an address from your lbry wallet
},
analytics: {
googleId: null, // google id for analytics tracking; leave `null` if not applicable
},
@ -29,8 +26,10 @@ module.exports = {
description: 'Open-source, decentralized image and video sharing.'
},
publish: {
primaryClaimAddress : null, // choose any address from your lbry wallet
additionalClaimAddresses: [], // // optional: add previously used claim addresses
thumbnailChannel : '@channelName', // create a channel to use for thumbnail images
thumbnailChannelId: 'xyz123...', // the channel_id (claim id) for the channel above
thumbnailChannelId : 'xyz123...', // the channel_id (claim id) for the channel above
}
claim: {
defaultTitle : 'Spee.ch',

View file

@ -2,7 +2,7 @@ const logger = require('winston');
const db = require('../models');
const lbryApi = require('../helpers/lbryApi.js');
const publishHelpers = require('../helpers/publishHelpers.js');
const config = require('../config/speechConfig.js');
const { publish : { primaryClaimAddress, additionalClaimAddresses } } = require('../config/speechConfig.js');
module.exports = {
publish (publishParams, fileName, fileType) {
@ -95,10 +95,11 @@ module.exports = {
})
.then(result => {
if (result.length >= 1) {
const claimAddress = config.wallet.lbryClaimAddress;
const claimAddresses = additionalClaimAddresses || [];
claimAddresses.push(primaryClaimAddress);
// filter out any that were not published from this address
const filteredResult = result.filter((claim) => {
return (claim.address === claimAddress);
const filteredResult = result.filter(({ address }) => {
return (claimAddresses.includes(address));
});
if (filteredResult.length >= 1) {
throw new Error('That claim is already in use');

View file

@ -1,6 +1,6 @@
const logger = require('winston');
const fs = require('fs');
const { site, wallet, publish } = require('../config/speechConfig.js');
const { site, publish } = require('../config/speechConfig.js');
module.exports = {
parsePublishApiRequestBody ({name, nsfw, license, title, description, thumbnail}) {
@ -114,7 +114,7 @@ module.exports = {
license,
nsfw,
},
claim_address: wallet.lbryClaimAddress,
claim_address: publish.primaryClaimAddress,
};
// add thumbnail to channel if video
if (thumbnail) {
@ -140,7 +140,7 @@ module.exports = {
license,
nsfw,
},
claim_address: wallet.lbryClaimAddress,
claim_address: publish.primaryClaimAddress,
channel_name : publish.thumbnailChannel,
channel_id : publish.thumbnailChannelId,
};