From 6b1069f02ad98da8a4ceb58be04f37e99fa999e6 Mon Sep 17 00:00:00 2001 From: Franco Montenegro Date: Tue, 9 Aug 2022 11:19:23 -0400 Subject: [PATCH] Properly handle blacklisted claims. (#7665) * Properly handle blacklisted claims. * Identify blacklist cause and display the proper message. --- extras/lbryinc/redux/selectors/ban.js | 9 +++- flow-typed/Claim.js | 37 +++++++++++++ ui/page/show/index.js | 8 ++- ui/page/show/view.jsx | 78 ++++++++++++++------------- ui/redux/actions/claims.js | 2 +- ui/redux/reducers/claims.js | 14 +++-- ui/redux/selectors/claims.js | 41 ++++++++++++++ 7 files changed, 142 insertions(+), 47 deletions(-) diff --git a/extras/lbryinc/redux/selectors/ban.js b/extras/lbryinc/redux/selectors/ban.js index ee0e2b0a0..88cec158b 100644 --- a/extras/lbryinc/redux/selectors/ban.js +++ b/extras/lbryinc/redux/selectors/ban.js @@ -5,7 +5,7 @@ // involve moving it from 'extras' to 'ui' (big change). import { createCachedSelector } from 're-reselect'; -import { selectClaimForUri } from 'redux/selectors/claims'; +import { selectClaimForUri, makeSelectIsBlacklisted } from 'redux/selectors/claims'; import { selectMutedChannels } from 'redux/selectors/blocked'; import { selectModerationBlockList } from 'redux/selectors/comments'; import { selectBlacklistedOutpointMap, selectFilteredOutpointMap } from 'lbryinc'; @@ -18,7 +18,8 @@ export const selectBanStateForUri = createCachedSelector( selectFilteredOutpointMap, selectMutedChannels, selectModerationBlockList, - (claim, blackListedOutpointMap, filteredOutpointMap, mutedChannelUris, personalBlocklist) => { + (state, uri) => makeSelectIsBlacklisted(uri)(state), + (claim, blackListedOutpointMap, filteredOutpointMap, mutedChannelUris, personalBlocklist, isBlacklisted) => { const banState = {}; if (!claim) { @@ -27,6 +28,10 @@ export const selectBanStateForUri = createCachedSelector( const channelClaim = getChannelFromClaim(claim); + if (isBlacklisted) { + banState['blacklisted'] = true; + } + // This will be replaced once blocking is done at the wallet server level. if (blackListedOutpointMap) { if ( diff --git a/flow-typed/Claim.js b/flow-typed/Claim.js index e03eeae81..4c3a63150 100644 --- a/flow-typed/Claim.js +++ b/flow-typed/Claim.js @@ -145,12 +145,49 @@ declare type PurchaseReceipt = { type: 'purchase', }; +declare type ClaimErrorCensor = { + address: string, + amount: string, + canonical_url: string, + claim_id: string, + claim_op: string, + confirmations: number, + has_signing_key: boolean, + height: number, + meta: { + activation_height: number, + claims_in_channel: number, + creation_height: number, + creation_timestamp: number, + effective_amount: string, + expiration_height: number, + is_controlling: boolean, + reposted: number, + support_amount: string, + take_over_height: number, + }, + name: string, + normalized_name: string, + nout: number, + permanent_url: string, + short_url: string, + timestamp: number, + txid: string, + type: string, + value: { + public_key: string, + public_key_id: string, + }, + value_type: string, +} + declare type ClaimActionResolveInfo = { [string]: { stream: ?StreamClaim, channel: ?ChannelClaim, claimsInChannel: ?number, collection: ?CollectionClaim, + errorCensor: ?ClaimErrorCensor, }, } diff --git a/ui/page/show/index.js b/ui/page/show/index.js index 974af2a7b..eb0f54f48 100644 --- a/ui/page/show/index.js +++ b/ui/page/show/index.js @@ -10,6 +10,9 @@ import { selectTitleForUri, selectClaimIsMine, makeSelectClaimIsPending, + makeSelectIsBlacklisted, + makeSelectBlacklistedDueToDMCA, + makeSelectClaimErrorCensor, } from 'redux/selectors/claims'; import { makeSelectCollectionForId, @@ -23,7 +26,6 @@ import { normalizeURI } from 'util/lbryURI'; import * as COLLECTIONS_CONSTS from 'constants/collections'; import { push } from 'connected-react-router'; import { makeSelectChannelInSubscriptions } from 'redux/selectors/subscriptions'; -import { selectBlackListedOutpoints } from 'lbryinc'; import ShowPage from './view'; const select = (state, props) => { @@ -72,7 +74,6 @@ const select = (state, props) => { uri, claim, isResolvingUri: selectIsUriResolving(state, uri), - blackListedOutpoints: selectBlackListedOutpoints(state), totalPages: makeSelectTotalPagesForChannel(uri, PAGE_SIZE)(state), isSubscribed: makeSelectChannelInSubscriptions(uri)(state), title: selectTitleForUri(state, uri), @@ -82,6 +83,9 @@ const select = (state, props) => { collectionId: collectionId, collectionUrls: makeSelectUrlsForCollectionId(collectionId)(state), isResolvingCollection: makeSelectIsResolvingCollectionForId(collectionId)(state), + isBlacklisted: makeSelectIsBlacklisted(uri)(state), + isBlacklistedDueToDMCA: makeSelectBlacklistedDueToDMCA(uri)(state), + errorCensor: makeSelectClaimErrorCensor(uri)(state), }; }; diff --git a/ui/page/show/view.jsx b/ui/page/show/view.jsx index 08342a665..5589ecffb 100644 --- a/ui/page/show/view.jsx +++ b/ui/page/show/view.jsx @@ -22,10 +22,6 @@ type Props = { uri: string, claim: StreamClaim, location: UrlLocation, - blackListedOutpoints: Array<{ - txid: string, - nout: number, - }>, title: string, claimIsMine: boolean, claimIsPending: boolean, @@ -35,6 +31,9 @@ type Props = { collectionUrls: Array, isResolvingCollection: boolean, fetchCollectionItems: (string) => void, + isBlacklisted: boolean, + isBlacklistedDueToDMCA: boolean, + errorCensor: ?ClaimErrorCensor, }; function ShowPage(props: Props) { @@ -43,7 +42,6 @@ function ShowPage(props: Props) { resolveUri, uri, claim, - blackListedOutpoints, location, claimIsMine, isSubscribed, @@ -54,11 +52,13 @@ function ShowPage(props: Props) { collection, collectionUrls, isResolvingCollection, + isBlacklisted, + isBlacklistedDueToDMCA, + errorCensor, } = props; const { search } = location; - const signingChannel = claim && claim.signing_channel; const canonicalUrl = claim && claim.canonical_url; const claimExists = claim !== null && claim !== undefined; const haventFetchedYet = claim === undefined; @@ -103,7 +103,7 @@ function ShowPage(props: Props) { } let innerContent = ''; - if (!claim || (claim && !claim.name)) { + if ((!claim || (claim && !claim.name)) && !isBlacklisted) { innerContent = ( {(claim === undefined || @@ -142,38 +142,42 @@ function ShowPage(props: Props) { {!isResolvingUri && isSubscribed && claim === null && } ); - } else if (claim.name.length && claim.name[0] === '@') { + } else if (claim && claim.name.length && claim.name[0] === '@') { innerContent = ; + } else if (isBlacklisted && !claimIsMine) { + innerContent = isBlacklistedDueToDMCA ? ( + + +