Run the extra app-side comment filter only if the claim is not ours.

## Preamble
- The app-side uses a cached blocklist, so when a Timeout expires, it doesn't know that the ban has been lifted.
- Meanwhile, we are doing extra comment filtering using this blocklist (so that we don't see comments that we have blocked, regardless of whose claim we are viewing).

## Issue
In a livestream, if a new message from an ex-offender comes in after their ban has been lifted, we do get the websocket message but it's being filtered out locally as mentioned above. So, the msg ended up being visible for everyone except the owner.

## Fix (band aid)
- Don't run the extra filter if the claim we are viewing is ours -- commentron would have filtered it for us anyways, and is the right logic to use even before this Timeout feature is introduced.
    - For the case of Timeout, this only serves as a band-aid until Commentron Issue 80 is available for us to detect the ban has been lifted. This is because it doesn't handle the case where I am a viewer and I decided to timeout someone for a few minutes. Because I am not the owner of the claim, the offender will continue to be blocked due to the same issue mentioned above.
This commit is contained in:
infinite-persistence 2021-09-03 15:43:01 +08:00
parent 804edd3308
commit bf8ab2e9ce
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -214,7 +214,7 @@ export const makeSelectCommentsForUri = (uri: string) =>
(state, byClaimId, byUri) => {
const claimId = byUri[uri];
const comments = byClaimId && byClaimId[claimId];
return makeSelectFilteredComments(comments)(state);
return makeSelectFilteredComments(comments, claimId)(state);
}
);
@ -226,7 +226,7 @@ export const makeSelectTopLevelCommentsForUri = (uri: string) =>
(state, byClaimId, byUri) => {
const claimId = byUri[uri];
const comments = byClaimId && byClaimId[claimId];
return makeSelectFilteredComments(comments)(state);
return makeSelectFilteredComments(comments, claimId)(state);
}
);
@ -262,7 +262,13 @@ export const makeSelectRepliesForParentId = (id: string) =>
}
);
const makeSelectFilteredComments = (comments: Array<Comment>) =>
/**
* makeSelectFilteredComments
*
* @param comments List of comments to filter.
* @param claimId The claim that `comments` reside in.
*/
const makeSelectFilteredComments = (comments: Array<Comment>, claimId?: string) =>
createSelector(
selectClaimsById,
selectMyActiveClaims,
@ -315,12 +321,18 @@ const makeSelectFilteredComments = (comments: Array<Comment>) =>
}
}
return !(
mutedChannels.includes(comment.channel_url) ||
personalBlockList.includes(comment.channel_url) ||
adminBlockList.includes(comment.channel_url) ||
moderatorBlockList.includes(comment.channel_url)
);
if (claimId) {
const claimIdIsMine = myClaims && myClaims.size > 0 && myClaims.has(claimId);
if (!claimIdIsMine) {
return !(
personalBlockList.includes(comment.channel_url) ||
adminBlockList.includes(comment.channel_url) ||
moderatorBlockList.includes(comment.channel_url)
);
}
}
return !mutedChannels.includes(comment.channel_url);
})
: [];
}