add basic dmca message on embeds page

This commit is contained in:
Sean Yesmunt 2020-11-10 01:23:08 -05:00
parent ca6ce23494
commit e2b30b7d17
2 changed files with 44 additions and 2 deletions

View file

@ -8,7 +8,7 @@ import {
makeSelectIsUriResolving, makeSelectIsUriResolving,
} from 'lbry-redux'; } from 'lbry-redux';
import { doPlayUri } from 'redux/actions/content'; import { doPlayUri } from 'redux/actions/content';
import { makeSelectCostInfoForUri, doFetchCostInfoForUri } from 'lbryinc'; import { makeSelectCostInfoForUri, doFetchCostInfoForUri, selectBlackListedOutpoints } from 'lbryinc';
const select = (state, props) => { const select = (state, props) => {
const { match } = props; const { match } = props;
@ -21,6 +21,7 @@ const select = (state, props) => {
costInfo: makeSelectCostInfoForUri(uri)(state), costInfo: makeSelectCostInfoForUri(uri)(state),
streamingUrl: makeSelectStreamingUrlForUri(uri)(state), streamingUrl: makeSelectStreamingUrlForUri(uri)(state),
isResolvingUri: makeSelectIsUriResolving(uri)(state), isResolvingUri: makeSelectIsUriResolving(uri)(state),
blackListedOutpoints: selectBlackListedOutpoints(state),
}; };
}; };

View file

@ -5,6 +5,7 @@ import FileRender from 'component/fileRender';
import FileViewerEmbeddedTitle from 'component/fileViewerEmbeddedTitle'; import FileViewerEmbeddedTitle from 'component/fileViewerEmbeddedTitle';
import Spinner from 'component/spinner'; import Spinner from 'component/spinner';
import Button from 'component/button'; import Button from 'component/button';
import Card from 'component/common/card';
import { formatLbryUrlForWeb } from 'util/url'; import { formatLbryUrlForWeb } from 'util/url';
import { useHistory } from 'react-router'; import { useHistory } from 'react-router';
@ -17,11 +18,26 @@ type Props = {
streamingUrl: string, streamingUrl: string,
doFetchCostInfoForUri: string => void, doFetchCostInfoForUri: string => void,
isResolvingUri: boolean, isResolvingUri: boolean,
blackListedOutpoints: Array<{
txid: string,
nout: number,
}>,
}; };
// $FlowFixMe apparently flow thinks this is wrong. // $FlowFixMe apparently flow thinks this is wrong.
export const EmbedContext = React.createContext(); export const EmbedContext = React.createContext();
const EmbedWrapperPage = (props: Props) => { const EmbedWrapperPage = (props: Props) => {
const { resolveUri, claim, uri, doPlayUri, costInfo, streamingUrl, doFetchCostInfoForUri, isResolvingUri } = props; const {
resolveUri,
claim,
uri,
doPlayUri,
costInfo,
streamingUrl,
doFetchCostInfoForUri,
isResolvingUri,
blackListedOutpoints,
} = props;
const { const {
location: { search }, location: { search },
} = useHistory(); } = useHistory();
@ -33,6 +49,15 @@ const EmbedWrapperPage = (props: Props) => {
const noContentFound = !claim && !isResolvingUri; const noContentFound = !claim && !isResolvingUri;
const isPaidContent = costInfo && costInfo.cost > 0; const isPaidContent = costInfo && costInfo.cost > 0;
const contentLink = formatLbryUrlForWeb(uri); const contentLink = formatLbryUrlForWeb(uri);
const signingChannel = claim && claim.signing_channel;
const isClaimBlackListed =
claim &&
blackListedOutpoints &&
blackListedOutpoints.some(
outpoint =>
(signingChannel && outpoint.txid === signingChannel.txid && outpoint.nout === signingChannel.nout) ||
(outpoint.txid === claim.txid && outpoint.nout === claim.nout)
);
useEffect(() => { useEffect(() => {
if (resolveUri && uri && !haveClaim) { if (resolveUri && uri && !haveClaim) {
@ -49,6 +74,22 @@ const EmbedWrapperPage = (props: Props) => {
} }
}, [uri, haveClaim, doFetchCostInfoForUri]); }, [uri, haveClaim, doFetchCostInfoForUri]);
if (isClaimBlackListed) {
return (
<Card
title={uri}
subtitle={__(
'In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications.'
)}
actions={
<div className="section__actions">
<Button button="link" href="https://lbry.com/faq/dmca" label={__('Read More')} />
</div>
}
/>
);
}
return ( return (
<div <div
className={classnames('embed__wrapper', { className={classnames('embed__wrapper', {