e288833085
## Mistake Tried to simplify the logic between checking Channel vs Content claim, and ended up always checking against Channel. This is correct for commentron blocklists, but not blacklists where the txid is per claim. ## Changes - Restored original logic. - While at it, restore the usage of `selectClaimForUri` (i.e. no need to split into 4 selectors anymore), since we've updated the reducer to prevent invalidation from things like 'confirmation' and 'is_my_output'.
74 lines
2.5 KiB
JavaScript
74 lines
2.5 KiB
JavaScript
// @flow
|
|
|
|
// TODO: This should be in 'redux/selectors/claim.js'. Temporarily putting it
|
|
// here to get past importing issues with 'lbryinc', which the real fix might
|
|
// involve moving it from 'extras' to 'ui' (big change).
|
|
|
|
import { createCachedSelector } from 're-reselect';
|
|
import { selectClaimForUri } from 'redux/selectors/claims';
|
|
import { selectMutedChannels } from 'redux/selectors/blocked';
|
|
import { selectModerationBlockList } from 'redux/selectors/comments';
|
|
import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc';
|
|
import { getChannelFromClaim } from 'util/claim';
|
|
import { isURIEqual } from 'util/lbryURI';
|
|
|
|
export const selectBanStateForUri = createCachedSelector(
|
|
selectClaimForUri,
|
|
selectBlackListedOutpoints,
|
|
selectFilteredOutpoints,
|
|
selectMutedChannels,
|
|
selectModerationBlockList,
|
|
(claim, blackListedOutpoints, filteredOutpoints, mutedChannelUris, personalBlocklist) => {
|
|
const banState = {};
|
|
|
|
if (!claim) {
|
|
return banState;
|
|
}
|
|
|
|
const channelClaim = getChannelFromClaim(claim);
|
|
|
|
// This will be replaced once blocking is done at the wallet server level.
|
|
if (blackListedOutpoints) {
|
|
if (
|
|
blackListedOutpoints.some(
|
|
(outpoint) =>
|
|
(channelClaim && outpoint.txid === channelClaim.txid && outpoint.nout === channelClaim.nout) ||
|
|
(outpoint.txid === claim.txid && outpoint.nout === claim.nout)
|
|
)
|
|
) {
|
|
banState['blacklisted'] = true;
|
|
}
|
|
}
|
|
|
|
// We're checking to see if the stream outpoint or signing channel outpoint
|
|
// is in the filter list.
|
|
if (filteredOutpoints) {
|
|
if (
|
|
filteredOutpoints.some(
|
|
(outpoint) =>
|
|
(channelClaim && outpoint.txid === channelClaim.txid && outpoint.nout === channelClaim.nout) ||
|
|
(outpoint.txid === claim.txid && outpoint.nout === claim.nout)
|
|
)
|
|
) {
|
|
banState['filtered'] = true;
|
|
}
|
|
}
|
|
|
|
// block stream claims
|
|
// block channel claims if we can't control for them in claim search
|
|
if (mutedChannelUris.length && channelClaim) {
|
|
if (mutedChannelUris.some((blockedUri) => isURIEqual(blockedUri, channelClaim.permanent_url))) {
|
|
banState['muted'] = true;
|
|
}
|
|
}
|
|
|
|
// Commentron blocklist
|
|
if (personalBlocklist.length && channelClaim) {
|
|
if (personalBlocklist.some((blockedUri) => isURIEqual(blockedUri, channelClaim.permanent_url))) {
|
|
banState['blocked'] = true;
|
|
}
|
|
}
|
|
|
|
return banState;
|
|
}
|
|
)((state, uri) => String(uri));
|