Merge pull request #867 from lbryio/staging

Cut release from staging
This commit is contained in:
Shawn K 2019-01-09 12:55:09 -06:00 committed by GitHub
commit e6c1f1da04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 388 additions and 258 deletions

View file

@ -2,5 +2,6 @@ client/build
node_modules/
public/bundle
server/render/build
server/bundle
test/
server/chainquery

View file

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2017-2018 LBRY Inc.
Copyright (c) 2017-2019 LBRY Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish,

View file

@ -17,7 +17,8 @@
"ipAddress": "",
"host": "https://www.example.com",
"description": "A decentralized hosting platform built on LBRY",
"twitter": false
"twitter": false,
"blockListEndpoint": "https://api.lbry.io/file/list_blocked"
},
"publishing": {
"primaryClaimAddress": null,

View file

@ -2,6 +2,16 @@
position: relative;
}
.asset-preview__blocked {
box-sizing: border-box;
background: black;
color: white;
height: 80%;
padding: 5px;
//remove margin-bottom after mystery 5px on wrapper is gone.
margin-bottom: 5px;
}
.asset-preview__image {
width : 100%;
padding: 0;

View file

@ -2,51 +2,59 @@ import React from 'react';
import { Link } from 'react-router-dom';
import createCanonicalLink from '../../../../utils/createCanonicalLink';
const ClaimPending = () => {
return (
<div className='claim-pending'>PENDING</div>
);
};
const AssetPreview = ({ defaultThumbnail, claimData }) => {
const {name, fileExt, contentType, thumbnail, title, pending} = claimData;
const {name, fileExt, contentType, thumbnail, title, blocked} = claimData;
const showUrl = createCanonicalLink({asset: {...claimData}});
const embedUrl = `${showUrl}.${fileExt}`;
switch (contentType) {
case 'image/jpeg':
case 'image/jpg':
case 'image/png':
case 'image/gif':
return (
<Link to={showUrl} className='asset-preview'>
<div>
/*
This blocked section shouldn't be necessary after pagination is reworked,
though it might be useful for channel_mine situations.
*/
if (blocked) {
return (
<div className='asset-preview'>
<div className='asset-preview__blocked'>
<h3>Error 451</h3>
<p>This content is blocked for legal reasons.</p>
</div>
<h3 className='asset-preview__title'>Blocked Content</h3>
</div>
);
} else {
switch (contentType) {
case 'image/jpeg':
case 'image/jpg':
case 'image/png':
case 'image/gif':
return (
<Link to={showUrl} className='asset-preview'>
<img
className={'asset-preview__image'}
src={embedUrl}
alt={name}
/>
<h3 className='asset-preview__title'>{title}</h3>
</div>
</Link>
);
case 'video/mp4':
return (
<Link to={showUrl} className='asset-preview'>
<div>
</Link>
);
case 'video/mp4':
return (
<Link to={showUrl} className='asset-preview'>
<div className='asset-preview__play-wrapper'>
<img
className={'asset-preview__video'}
src={thumbnail || defaultThumbnail}
alt={name}
/>
<div className='asset-preview__play-overlay'></div>
<div className='asset-preview__play-overlay' />
</div>
<h3 className='asset-preview__title'>{title}</h3>
</div>
</Link>
);
default:
return null;
</Link>
);
default:
return null;
}
}
};

View file

@ -0,0 +1,13 @@
import { connect } from 'react-redux';
import View from './view';
import { selectAsset } from '../../selectors/show';
const mapStateToProps = (props) => {
const {show} = props;
const asset = selectAsset(show);
return {
asset,
};
};
export default connect(mapStateToProps, null)(View);

View file

@ -0,0 +1,58 @@
import React from 'react';
import createCanonicalLink from '../../../../utils/createCanonicalLink';
import HorizontalSplit from '@components/HorizontalSplit';
/*
This component shouldn't be necessary after pagination is reworked,
though it might be useful for channel_mine situations.
*/
class BlockedLeft extends React.PureComponent {
render () {
return (
<React.Fragment>
<img className='asset-image' src={'https://upload.wikimedia.org/wikipedia/commons/archive/a/af/20120315000030%21OR_451.svg'} alt={'451 image'} />
</React.Fragment>
);
}
}
class BlockedRight extends React.PureComponent {
render () {
return (
<React.Fragment>
<p>In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications.</p>
<p><a href={'https://lbry.io/faq/dmca'} >Click here</a> for more information.</p>
</React.Fragment>
);
}
}
class AssetBlocked extends React.Component {
componentDidMount () {
/*
This function and fetch exists to send the browser the appropriate 451 error.
*/
const { asset } = this.props;
const { claimData: { contentType, outpoint } } = asset;
let fileExt;
if (typeof contentType === 'string') {
fileExt = contentType.split('/')[1] || 'jpg';
}
const sourceUrl = `${createCanonicalLink({ asset: asset.claimData })}.${fileExt}?${outpoint}`;
fetch(sourceUrl)
.catch();
}
render () {
return (
<div>
<HorizontalSplit
collapseOnMobile
leftSide={<BlockedLeft />}
rightSide={<BlockedRight />}
/>
</div>
);
}
};
export default AssetBlocked;

View file

@ -104,7 +104,7 @@ class AssetInfo extends React.Component {
{(contentType === 'video/mp4') ? (
<ClickToCopy
id={'embed-text-video'}
value={`<iframe src="${host}/video-embed${canonicalUrl}" allowfullscreen="true" style="border:0" /></iframe>`}
value={`<iframe src="${host}/video-embed${canonicalUrl}" allowfullscreen="true" style="border:0"></iframe>`}
/>
) : (
<ClickToCopy

View file

@ -2,6 +2,7 @@ import React from 'react';
import PageLayout from '@components/PageLayout';
import * as Icon from 'react-feather';
import AssetDisplay from '@containers/AssetDisplay';
import AssetBlocked from '@containers/AssetBlocked';
import AssetInfo from '@containers/AssetInfo';
import ErrorPage from '@pages/ErrorPage';
import AssetTitle from '@containers/AssetTitle';
@ -29,23 +30,32 @@ class ShowAssetDetails extends React.Component {
render () {
const { asset } = this.props;
if (asset) {
const { claimData: { name } } = asset;
return (
<PageLayout
pageTitle={`${name} - details`}
asset={asset}
>
<div className="asset-main">
<AssetDisplay />
<AssetTitle />
<button className='collapse-button' onClick={this.collapse}>
{this.state.closed ? <Icon.PlusCircle className='plus-icon' /> : <Icon.MinusCircle />}
</button>
</div>
{!this.state.closed && <AssetInfo />}
</PageLayout>
);
const { claimData: { name, blocked } } = asset;
if (!blocked) {
return (
<PageLayout
pageTitle={`${name} - details`}
asset={asset}
>
<div className="asset-main">
<AssetDisplay />
<AssetTitle />
<button className='collapse-button' onClick={this.collapse}>
{this.state.closed ? <Icon.PlusCircle className='plus-icon' /> : <Icon.MinusCircle />}
</button>
</div>
{!this.state.closed && <AssetInfo />}
</PageLayout>
);
} else {
return (
<PageLayout>
<div className="asset-main">
<AssetBlocked />
</div>
</PageLayout>
);
}
}
return (
<ErrorPage error={'loading asset data...'} />

310
package-lock.json generated
View file

@ -2050,33 +2050,29 @@
"dev": true
},
"bcrypt": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-2.0.1.tgz",
"integrity": "sha512-DwB7WgJPdskbR+9Y3OTJtwRq09Lmm7Na6b+4ewvXjkD0nfNRi1OozxljHm5ETlDCBq9DTy04lQz+rj+T2ztIJg==",
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-3.0.3.tgz",
"integrity": "sha512-4EuzUo6K790QC3uq/ogzy9w2Hc7XDIBoEndU5y7l7YaEAwQF8vyFqv6tC30+gOBZvyxk3F632xzKBQoLNz2pjg==",
"requires": {
"nan": "2.10.0",
"node-pre-gyp": "0.9.1"
"nan": "2.12.1",
"node-pre-gyp": "0.12.0"
},
"dependencies": {
"abbrev": {
"version": "1.1.1",
"resolved": false,
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q=="
"bundled": true
},
"ansi-regex": {
"version": "2.1.1",
"resolved": false,
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
"bundled": true
},
"aproba": {
"version": "1.2.0",
"resolved": false,
"integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw=="
"bundled": true
},
"are-we-there-yet": {
"version": "1.1.4",
"resolved": false,
"integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=",
"version": "1.1.5",
"bundled": true,
"requires": {
"delegates": "^1.0.0",
"readable-stream": "^2.0.6"
@ -2084,78 +2080,69 @@
},
"balanced-match": {
"version": "1.0.0",
"resolved": false,
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
"bundled": true
},
"brace-expansion": {
"version": "1.1.11",
"resolved": false,
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"bundled": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"chownr": {
"version": "1.0.1",
"resolved": false,
"integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE="
"version": "1.1.1",
"bundled": true
},
"code-point-at": {
"version": "1.1.0",
"resolved": false,
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
"bundled": true
},
"concat-map": {
"version": "0.0.1",
"resolved": false,
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
"bundled": true
},
"console-control-strings": {
"version": "1.1.0",
"resolved": false,
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4="
"bundled": true
},
"core-util-is": {
"version": "1.0.2",
"resolved": false,
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
"bundled": true
},
"debug": {
"version": "2.6.9",
"resolved": false,
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"bundled": true,
"requires": {
"ms": "2.0.0"
}
},
"deep-extend": {
"version": "0.6.0",
"bundled": true
},
"delegates": {
"version": "1.0.0",
"resolved": false,
"integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o="
"bundled": true
},
"detect-libc": {
"version": "1.0.3",
"resolved": false,
"integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups="
"bundled": true
},
"fs-minipass": {
"version": "1.2.5",
"resolved": false,
"integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==",
"bundled": true,
"requires": {
"minipass": "^2.2.1"
}
},
"fs.realpath": {
"version": "1.0.0",
"resolved": false,
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
"bundled": true
},
"gauge": {
"version": "2.7.4",
"resolved": false,
"integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=",
"bundled": true,
"requires": {
"aproba": "^1.0.3",
"console-control-strings": "^1.0.0",
@ -2169,8 +2156,7 @@
},
"glob": {
"version": "7.1.2",
"resolved": false,
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"bundled": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@ -2182,29 +2168,25 @@
},
"has-unicode": {
"version": "2.0.1",
"resolved": false,
"integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk="
"bundled": true
},
"iconv-lite": {
"version": "0.4.21",
"resolved": false,
"integrity": "sha512-En5V9za5mBt2oUA03WGD3TwDv0MKAruqsuxstbMUZaj9W9k/m1CV/9py3l0L5kw9Bln8fdHQmzHSYtvpvTLpKw==",
"version": "0.4.24",
"bundled": true,
"requires": {
"safer-buffer": "^2.1.0"
"safer-buffer": ">= 2.1.2 < 3"
}
},
"ignore-walk": {
"version": "3.0.1",
"resolved": false,
"integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==",
"bundled": true,
"requires": {
"minimatch": "^3.0.4"
}
},
"inflight": {
"version": "1.0.6",
"resolved": false,
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"bundled": true,
"requires": {
"once": "^1.3.0",
"wrappy": "1"
@ -2212,76 +2194,78 @@
},
"inherits": {
"version": "2.0.3",
"resolved": false,
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
"bundled": true
},
"ini": {
"version": "1.3.5",
"bundled": true
},
"is-fullwidth-code-point": {
"version": "1.0.0",
"resolved": false,
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
"bundled": true,
"requires": {
"number-is-nan": "^1.0.0"
}
},
"isarray": {
"version": "1.0.0",
"resolved": false,
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
"bundled": true
},
"minimatch": {
"version": "3.0.4",
"resolved": false,
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"bundled": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"resolved": false,
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
"bundled": true
},
"minipass": {
"version": "2.2.4",
"resolved": false,
"integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==",
"version": "2.3.4",
"bundled": true,
"requires": {
"safe-buffer": "^5.1.1",
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
},
"dependencies": {
"safe-buffer": {
"version": "5.1.2",
"bundled": true
},
"yallist": {
"version": "3.0.2",
"resolved": false,
"integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k="
"bundled": true
}
}
},
"minizlib": {
"version": "1.1.0",
"resolved": false,
"integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==",
"version": "1.1.1",
"bundled": true,
"requires": {
"minipass": "^2.2.1"
}
},
"mkdirp": {
"version": "0.5.1",
"resolved": false,
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"bundled": true,
"requires": {
"minimist": "0.0.8"
}
},
"ms": {
"version": "2.0.0",
"resolved": false,
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
"bundled": true
},
"nan": {
"version": "2.12.1",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.12.1.tgz",
"integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw=="
},
"needle": {
"version": "2.2.0",
"resolved": false,
"integrity": "sha512-eFagy6c+TYayorXw/qtAdSvaUpEbBsDwDyxYFgLZ0lTojfH7K+OdBqAF7TAFwDokJaGpubpSGG0wO3iC0XPi8w==",
"version": "2.2.4",
"bundled": true,
"requires": {
"debug": "^2.1.2",
"iconv-lite": "^0.4.4",
@ -2289,17 +2273,16 @@
}
},
"node-pre-gyp": {
"version": "0.9.1",
"resolved": false,
"integrity": "sha1-8RwHUW3ZL4cZnbx+GDjqt81WyeA=",
"version": "0.12.0",
"bundled": true,
"requires": {
"detect-libc": "^1.0.2",
"mkdirp": "^0.5.1",
"needle": "^2.2.0",
"needle": "^2.2.1",
"nopt": "^4.0.1",
"npm-packlist": "^1.1.6",
"npmlog": "^4.0.2",
"rc": "^1.1.7",
"rc": "^1.2.7",
"rimraf": "^2.6.1",
"semver": "^5.3.0",
"tar": "^4"
@ -2307,22 +2290,19 @@
},
"nopt": {
"version": "4.0.1",
"resolved": false,
"integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=",
"bundled": true,
"requires": {
"abbrev": "1",
"osenv": "^0.1.4"
}
},
"npm-bundled": {
"version": "1.0.3",
"resolved": false,
"integrity": "sha512-ByQ3oJ/5ETLyglU2+8dBObvhfWXX8dtPZDMePCahptliFX2iIuhyEszyFk401PZUNQH20vvdW5MLjJxkwU80Ow=="
"version": "1.0.5",
"bundled": true
},
"npm-packlist": {
"version": "1.1.10",
"resolved": false,
"integrity": "sha512-AQC0Dyhzn4EiYEfIUjCdMl0JJ61I2ER9ukf/sLxJUcZHfo+VyEfz2rMJgLZSS1v30OxPQe1cN0LZA1xbcaVfWA==",
"version": "1.1.12",
"bundled": true,
"requires": {
"ignore-walk": "^3.0.1",
"npm-bundled": "^1.0.1"
@ -2330,8 +2310,7 @@
},
"npmlog": {
"version": "4.1.2",
"resolved": false,
"integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==",
"bundled": true,
"requires": {
"are-we-there-yet": "~1.1.2",
"console-control-strings": "~1.1.0",
@ -2341,36 +2320,30 @@
},
"number-is-nan": {
"version": "1.0.1",
"resolved": false,
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0="
"bundled": true
},
"object-assign": {
"version": "4.1.1",
"resolved": false,
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
"bundled": true
},
"once": {
"version": "1.4.0",
"resolved": false,
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"bundled": true,
"requires": {
"wrappy": "1"
}
},
"os-homedir": {
"version": "1.0.2",
"resolved": false,
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M="
"bundled": true
},
"os-tmpdir": {
"version": "1.0.2",
"resolved": false,
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ="
"bundled": true
},
"osenv": {
"version": "0.1.5",
"resolved": false,
"integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==",
"bundled": true,
"requires": {
"os-homedir": "^1.0.0",
"os-tmpdir": "^1.0.0"
@ -2378,18 +2351,15 @@
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": false,
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
"bundled": true
},
"process-nextick-args": {
"version": "2.0.0",
"resolved": false,
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
"bundled": true
},
"rc": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz",
"integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==",
"bundled": true,
"requires": {
"deep-extend": "^0.6.0",
"ini": "~1.3.0",
@ -2399,15 +2369,13 @@
"dependencies": {
"minimist": {
"version": "1.2.0",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
"bundled": true
}
}
},
"readable-stream": {
"version": "2.3.5",
"resolved": false,
"integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==",
"bundled": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
@ -2420,46 +2388,38 @@
},
"rimraf": {
"version": "2.6.2",
"resolved": false,
"integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==",
"bundled": true,
"requires": {
"glob": "^7.0.5"
}
},
"safe-buffer": {
"version": "5.1.1",
"resolved": false,
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
"bundled": true
},
"safer-buffer": {
"version": "2.1.2",
"resolved": false,
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
"bundled": true
},
"sax": {
"version": "1.2.4",
"resolved": false,
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
"bundled": true
},
"semver": {
"version": "5.5.0",
"resolved": false,
"integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA=="
"version": "5.6.0",
"bundled": true
},
"set-blocking": {
"version": "2.0.0",
"resolved": false,
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc="
"bundled": true
},
"signal-exit": {
"version": "3.0.2",
"resolved": false,
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0="
"bundled": true
},
"string-width": {
"version": "1.0.2",
"resolved": false,
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
"bundled": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -2468,58 +2428,59 @@
},
"string_decoder": {
"version": "1.0.3",
"resolved": false,
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
"bundled": true,
"requires": {
"safe-buffer": "~5.1.0"
}
},
"strip-ansi": {
"version": "3.0.1",
"resolved": false,
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"bundled": true,
"requires": {
"ansi-regex": "^2.0.0"
}
},
"strip-json-comments": {
"version": "2.0.1",
"bundled": true
},
"tar": {
"version": "4.4.1",
"resolved": false,
"integrity": "sha512-O+v1r9yN4tOsvl90p5HAP4AEqbYhx4036AGMm075fH9F8Qwi3oJ+v4u50FkT/KkvywNGtwkk0zRI+8eYm1X/xg==",
"version": "4.4.8",
"bundled": true,
"requires": {
"chownr": "^1.0.1",
"chownr": "^1.1.1",
"fs-minipass": "^1.2.5",
"minipass": "^2.2.4",
"minizlib": "^1.1.0",
"minipass": "^2.3.4",
"minizlib": "^1.1.1",
"mkdirp": "^0.5.0",
"safe-buffer": "^5.1.1",
"safe-buffer": "^5.1.2",
"yallist": "^3.0.2"
},
"dependencies": {
"safe-buffer": {
"version": "5.1.2",
"bundled": true
},
"yallist": {
"version": "3.0.2",
"resolved": false,
"integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k="
"bundled": true
}
}
},
"util-deprecate": {
"version": "1.0.2",
"resolved": false,
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
"bundled": true
},
"wide-align": {
"version": "1.1.2",
"resolved": false,
"integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==",
"version": "1.1.3",
"bundled": true,
"requires": {
"string-width": "^1.0.2"
"string-width": "^1.0.2 || 2"
}
},
"wrappy": {
"version": "1.0.2",
"resolved": false,
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
"bundled": true
}
}
},
@ -3943,7 +3904,8 @@
"deep-extend": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz",
"integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA=="
"integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==",
"dev": true
},
"deep-is": {
"version": "0.1.3",
@ -7315,9 +7277,9 @@
}
},
"js-base64": {
"version": "2.4.9",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.4.9.tgz",
"integrity": "sha512-xcinL3AuDJk7VSzsHgb9DvvIXayBbadtMZ4HFPx8rUszbW1MuNMlwYVC4zzCZ6e1sqZpnNS5ZFYOhXqA39T7LQ==",
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.5.0.tgz",
"integrity": "sha512-wlEBIZ5LP8usDylWbDNhKPEFVFdI5hCHpnVoT/Ysvoi/PRhJENm/Rlh9TvjYB38HFfKZN7OzEbRjmjvLkFw11g==",
"dev": true
},
"js-beautify": {
@ -8183,7 +8145,8 @@
"nan": {
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz",
"integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA=="
"integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==",
"dev": true
},
"nanomatch": {
"version": "1.2.13",
@ -8394,9 +8357,9 @@
}
},
"node-sass": {
"version": "4.10.0",
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.10.0.tgz",
"integrity": "sha512-fDQJfXszw6vek63Fe/ldkYXmRYK/QS6NbvM3i5oEo9ntPDy4XX7BcKZyTKv+/kSSxRtXXc7l+MSwEmYc0CSy6Q==",
"version": "4.11.0",
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.11.0.tgz",
"integrity": "sha512-bHUdHTphgQJZaF1LASx0kAviPH7sGlcyNhWade4eVIpFp6tsn7SV8xNMTbsQFpEV9VXpnwTTnNYlfsZXgGgmkA==",
"dev": true,
"requires": {
"async-foreach": "^0.1.3",
@ -12783,17 +12746,6 @@
"requires": {
"indent-string": "^2.1.0",
"strip-indent": "^1.0.1"
},
"dependencies": {
"strip-indent": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz",
"integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=",
"dev": true,
"requires": {
"get-stdin": "^4.0.1"
}
}
}
},
"redux": {
@ -14207,10 +14159,20 @@
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
"integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8="
},
"strip-indent": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz",
"integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=",
"dev": true,
"requires": {
"get-stdin": "^4.0.1"
}
},
"strip-json-comments": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
"integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo="
"integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=",
"dev": true
},
"style-loader": {
"version": "0.23.1",

View file

@ -37,7 +37,7 @@
"@fortawesome/free-solid-svg-icons": "^5.5.0",
"@fortawesome/react-fontawesome": "^0.1.3",
"axios": "^0.18.0",
"bcrypt": "^2.0.1",
"bcrypt": "^3.0.3",
"body-parser": "^1.18.3",
"connect-multiparty": "^2.2.0",
"cookie-session": "^2.0.0-beta.3",
@ -108,7 +108,7 @@
"mini-css-extract-plugin": "^0.5.0",
"mocha": "^5.2.0",
"ndb": "^1.0.26",
"node-sass": "^4.10.0",
"node-sass": "^4.11.0",
"nodemon": "^1.18.6",
"react-color": "^2.14.1",
"react-hot-loader": "^4.6.0",

View file

@ -5,6 +5,7 @@ const getClaimData = require('server/utils/getClaimData');
const chainquery = require('chainquery').default;
const db = require('../../../../models');
const waitOn = require('wait-on');
const logger = require('winston');
/*
@ -17,32 +18,35 @@ const claimGet = async ({ ip, originalUrl, params }, res) => {
const claimId = params.claimId;
try {
let claimData = await chainquery.claim.queries.resolveClaim(name, claimId).catch(() => {});
if (!claimData) {
claimData = await db.Claim.resolveClaim(name, claimId);
let claimInfo = await chainquery.claim.queries.resolveClaim(name, claimId).catch(() => {});
if (claimInfo) {
logger.info('claim/get: claim resolved in chainquery');
}
if (!claimData) {
throw new Error('No matching uri found in Claim table');
if (!claimInfo) {
claimInfo = await db.Claim.resolveClaim(name, claimId);
}
if (!claimInfo) {
throw new Error('claim/get: resolveClaim: No matching uri found in Claim table');
}
let lbrynetResult = await getClaim(`${name}#${claimId}`);
if (!lbrynetResult) {
throw new Error(`Unable to Get ${name}#${claimId}`);
throw new Error(`claim/get: getClaim Unable to Get ${name}#${claimId}`);
}
const claimData = await getClaimData(claimInfo);
if (!claimData) {
throw new Error('claim/get: getClaimData failed to get file blobs');
}
await waitOn({
resources: [ lbrynetResult.download_path ],
timeout : 10000, // 10 seconds
window : 500,
});
const fileData = await createFileRecordDataAfterGet(claimData, lbrynetResult);
if (!fileData) {
throw new Error('claim/get: createFileRecordDataAfterGet failed to create file in time');
}
let fileData = await createFileRecordDataAfterGet(await getClaimData(claimData), lbrynetResult);
const upsertCriteria = { name, claimId };
await db.upsert(db.File, fileData, upsertCriteria, 'File');
try {
await waitOn({
resources: [ lbrynetResult.file_name ],
delay : 500,
timeout : 10000, // 10 seconds
});
} catch (e) {}
const { message, completed } = lbrynetResult;
res.status(200).json({
success: true,
@ -53,5 +57,4 @@ const claimGet = async ({ ip, originalUrl, params }, res) => {
handleErrorResponse(originalUrl, ip, error, res);
}
};
module.exports = claimGet;

View file

@ -16,6 +16,7 @@ const createDatabaseIfNotExists = require('./models/utils/createDatabaseIfNotExi
const { getWalletBalance } = require('./lbrynet/index');
const configureLogging = require('./utils/configureLogging');
const configureSlack = require('./utils/configureSlack');
const { setupBlockList } = require('./utils/blockList');
const speechPassport = require('./speechPassport');
const processTrending = require('./utils/processTrending');
@ -25,7 +26,7 @@ const {
} = require('./middleware/logMetricsMiddleware');
const {
details: { port: PORT },
details: { port: PORT, blockListEndpoint },
startup: {
performChecks,
performUpdates,
@ -34,6 +35,9 @@ const {
const { sessionKey } = require('@private/authConfig.json');
// configure.js doesn't handle new keys in config.json files yet. Make sure it doens't break.
let bLE;
function Server () {
this.initialize = () => {
// configure logging
@ -166,19 +170,37 @@ function Server () {
logger.info('Starting LBC balance:', walletBalance);
});
};
this.performUpdates = () => {
if (!performUpdates) {
return;
}
if (blockListEndpoint) {
bLE = blockListEndpoint;
} else if (!blockListEndpoint) {
if (typeof (blockListEndpoint) !== 'string') {
logger.warn('blockListEndpoint is null due to outdated siteConfig file. \n' +
'Continuing with default LBRY blocklist api endpoint. \n ' +
'(Specify /"blockListEndpoint" : ""/ to disable.')
bLE = 'https://api.lbry.io/file/list_blocked';
}
}
logger.info(`Peforming updates...`);
return Promise.all([
db.Blocked.refreshTable(),
db.Tor.refreshTable(),
])
.then(([updatedBlockedList, updatedTorList]) => {
logger.info('Blocked list updated, length:', updatedBlockedList.length);
if (!bLE) {
logger.info('Configured for no Block List')
db.Tor.refreshTable().then( (updatedTorList) => {
logger.info('Tor list updated, length:', updatedTorList.length);
});
} else {
return Promise.all([
db.Blocked.refreshTable(bLE),
db.Tor.refreshTable()])
.then(([updatedBlockedList, updatedTorList]) => {
logger.info('Blocked list updated, length:', updatedBlockedList.length);
logger.info('Tor list updated, length:', updatedTorList.length);
})
}
};
this.start = () => {
this.initialize();
@ -194,6 +216,9 @@ function Server () {
this.performUpdates(),
]);
})
.then(() => {
return setupBlockList();
})
.then(() => {
logger.info('Spee.ch startup is complete');

View file

@ -1,5 +1,4 @@
const logger = require('winston');
const BLOCKED_CLAIM = 'BLOCKED_CLAIM';
module.exports = (sequelize, { STRING }) => {
@ -16,6 +15,14 @@ module.exports = (sequelize, { STRING }) => {
}
);
Blocked.getBlockList = function () {
logger.debug('returning full block list');
return new Promise((resolve, reject) => {
this.findAll()
.then(list => { return resolve(list) });
});
};
Blocked.isNotBlocked = function (outpoint) {
logger.debug(`checking to see if ${outpoint} is not blocked`);
return new Promise((resolve, reject) => {
@ -37,9 +44,10 @@ module.exports = (sequelize, { STRING }) => {
});
};
Blocked.refreshTable = function () {
Blocked.refreshTable = function (blockEndpoint) {
let blockedList = [];
return fetch('https://api.lbry.io/file/list_blocked')
return fetch(blockEndpoint)
.then(response => {
return response.json();
})
@ -50,9 +58,7 @@ module.exports = (sequelize, { STRING }) => {
if (!jsonResponse.data.outpoints) {
throw new Error('no outpoints in list_blocked response');
}
return jsonResponse.data.outpoints;
})
.then(outpoints => {
let outpoints = jsonResponse.data.outpoints;
logger.debug('total outpoints:', outpoints.length);
// prep the records
for (let i = 0; i < outpoints.length; i++) {

26
server/utils/blockList.js Normal file
View file

@ -0,0 +1,26 @@
const logger = require('winston');
const db = require('../models');
let blockList = new Set();
const setupBlockList = (intervalInSeconds = 60) => {
const fetchList = () => {
return new Promise((resolve, reject) => {
db.Blocked.getBlockList()
.then((result) => {
blockList.clear();
if (result.length > 0) {
result.map((item) => { blockList.add(item.dataValues.outpoint) });
resolve();
} else reject();
})
.catch(e => { console.error('list was empty', e) });
});
};
setInterval(() => { fetchList() }, intervalInSeconds * 1000);
return fetchList();
};
module.exports = {
isBlocked: (outpoint) => { return blockList.has(outpoint) },
setupBlockList,
};

View file

@ -1,6 +1,7 @@
const { details: { host } } = require('@config/siteConfig');
const chainquery = require('chainquery').default;
const { getClaim } = require('server/lbrynet');
const { isBlocked } = require('./blockList');
module.exports = async (data, chName = null, chShortId = null) => {
// TODO: Refactor getching the channel name out; requires invasive changes.
@ -9,6 +10,11 @@ module.exports = async (data, chName = null, chShortId = null) => {
let lbrynetFileExt = null;
let channelShortId = chShortId;
let channelName = chName;
let blocked;
const outPoint = `${data.transaction_hash_id}:${data.vout}`;
if (isBlocked(outPoint)) {
blocked = true;
}
if (!chName && certificateId && !channelName) {
channelName = await chainquery.claim.queries.getClaimChannelName(certificateId).catch(() => {
@ -38,8 +44,9 @@ module.exports = async (data, chName = null, chShortId = null) => {
fileExt : data.generated_extension || data.fileExt || lbrynetFileExt,
description: data.description,
thumbnail : data.generated_thumbnail || data.thumbnail_url || data.thumbnail,
outpoint : `${data.transaction_hash_id}:${data.vout}` || data.outpoint,
outpoint : outPoint || data.outpoint,
host,
pending : Boolean(data.height === 0),
blocked : blocked,
});
};