From d018f58d8da3a8aebf05c93990b65693615da238 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Wed, 7 Mar 2018 20:06:52 -0800 Subject: [PATCH] added availability check based on multiple claim addresses --- config/speechConfig.js.example | 9 ++++----- controllers/publishController.js | 9 +++++---- helpers/publishHelpers.js | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config/speechConfig.js.example b/config/speechConfig.js.example index af4b1de7..21c32be5 100644 --- a/config/speechConfig.js.example +++ b/config/speechConfig.js.example @@ -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: { - thumbnailChannel : '@channelName', // create a channel to use for thumbnail images - thumbnailChannelId: 'xyz123...', // the channel_id (claim id) for the channel above + 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 } claim: { defaultTitle : 'Spee.ch', diff --git a/controllers/publishController.js b/controllers/publishController.js index 215160d8..e376ed47 100644 --- a/controllers/publishController.js +++ b/controllers/publishController.js @@ -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'); diff --git a/helpers/publishHelpers.js b/helpers/publishHelpers.js index 5e515834..1b894eea 100644 --- a/helpers/publishHelpers.js +++ b/helpers/publishHelpers.js @@ -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, };